aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada/sem_warn.adb
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/ada/sem_warn.adb')
-rw-r--r--gcc/ada/sem_warn.adb24
1 files changed, 19 insertions, 5 deletions
diff --git a/gcc/ada/sem_warn.adb b/gcc/ada/sem_warn.adb
index 3550392f872..b8ff44a72a1 100644
--- a/gcc/ada/sem_warn.adb
+++ b/gcc/ada/sem_warn.adb
@@ -236,12 +236,15 @@ package body Sem_Warn is
Iter : constant Node_Id := Iteration_Scheme (Loop_Statement);
Ref : Node_Id := Empty;
- -- Reference in iteration scheme to variable that may not be modified in
- -- loop, indicating a possible infinite loop.
+ -- Reference in iteration scheme to variable that might not be modified
+ -- in loop, indicating a possible infinite loop.
Var : Entity_Id := Empty;
-- Corresponding entity (entity of Ref)
+ Function_Call_Found : Boolean := False;
+ -- True if Find_Var found a function call in the condition
+
procedure Find_Var (N : Node_Id);
-- Inspect condition to see if it depends on a single entity reference.
-- If so, Ref is set to point to the reference node, and Var is set to
@@ -305,6 +308,8 @@ package body Sem_Warn is
elsif Nkind (N) = N_Function_Call then
+ Function_Call_Found := True;
+
-- Forget it if function name is not entity, who knows what
-- we might be calling?
@@ -541,7 +546,7 @@ package body Sem_Warn is
-- Start of processing for Check_Infinite_Loop_Warning
begin
- -- We need a while iteration with no condition actions. Conditions
+ -- We need a while iteration with no condition actions. Condition
-- actions just make things too complicated to get the warning right.
if No (Iter)
@@ -556,19 +561,25 @@ package body Sem_Warn is
Find_Var (Condition (Iter));
- -- Nothing to do if local variable from source not found
+ -- Nothing to do if local variable from source not found. If it's a
+ -- renaming, it is probably renaming something too complicated to deal
+ -- with here.
if No (Var)
or else Ekind (Var) /= E_Variable
or else Is_Library_Level_Entity (Var)
or else not Comes_From_Source (Var)
+ or else Nkind (Parent (Var)) = N_Object_Renaming_Declaration
then
return;
-- Nothing to do if there is some indirection involved (assume that the
-- designated variable might be modified in some way we don't see).
+ -- However, if no function call was found, then we don't care about
+ -- indirections, because the condition must be something like "while X
+ -- /= null loop", so we don't care if X.all is modified in the loop.
- elsif Has_Indirection (Etype (Var)) then
+ elsif Function_Call_Found and then Has_Indirection (Etype (Var)) then
return;
-- Same sort of thing for volatile variable, might be modified by
@@ -3006,6 +3017,7 @@ package body Sem_Warn is
when 'X' =>
Warn_On_Non_Local_Exception := False;
+ No_Warn_On_Non_Local_Exception := True;
when others =>
return False;
@@ -3079,6 +3091,8 @@ package body Sem_Warn is
Warn_On_Unrepped_Components := False;
Warn_On_Warnings_Off := False;
+ No_Warn_On_Non_Local_Exception := True;
+
when 'b' =>
Warn_On_Bad_Fixed_Value := True;