with Restrict; use Restrict;
with Rident; use Rident;
with Sem_Aux; use Sem_Aux;
+with Sem_Util; use Sem_Util;
with Snames; use Snames;
with Stand; use Stand;
with Stringt; use Stringt;
Has_Created_Identifier : Boolean := False;
End_Label : Node_Id := Empty) return Node_Id
is
- begin
- Check_Restriction (No_Implicit_Loops, Node);
+ P : Node_Id;
+ Check_Restrictions : Boolean := True;
+ begin
+ -- Do not check restrictions if the implicit loop statement is part
+ -- of a dead branch: False and then ...
+ -- This will occur in particular as part of the expansion of pragma
+ -- Assert when assertions are disabled.
+
+ P := Parent (Node);
+ while Present (P) loop
+ if Nkind (P) = N_And_Then then
+ if Nkind (Left_Opnd (P)) = N_Identifier
+ and then Entity (Left_Opnd (P)) = Standard_False
+ then
+ Check_Restrictions := False;
+ exit;
+ end if;
- if Present (Iteration_Scheme)
- and then Nkind (Iteration_Scheme) /= N_Iterator_Specification
- and then Present (Condition (Iteration_Scheme))
- then
- Check_Restriction (No_Implicit_Conditionals, Node);
+ -- Prevent the search from going too far
+
+ elsif Is_Body_Or_Package_Declaration (P) then
+ exit;
+ end if;
+
+ P := Parent (P);
+ end loop;
+
+ if Check_Restrictions then
+ Check_Restriction (No_Implicit_Loops, Node);
+
+ if Present (Iteration_Scheme)
+ and then Nkind (Iteration_Scheme) /= N_Iterator_Specification
+ and then Present (Condition (Iteration_Scheme))
+ then
+ Check_Restriction (No_Implicit_Conditionals, Node);
+ end if;
end if;
return Make_Loop_Statement (Sloc (Node),