diff options
author | Arnaud Charlet <charlet@adacore.com> | 2020-12-22 10:02:29 -0500 |
---|---|---|
committer | Pierre-Marie de Rodat <derodat@adacore.com> | 2021-05-03 05:28:21 -0400 |
commit | 56adf813f4e23d95d92385dee9b31e5e0d476abd (patch) | |
tree | 4b9c81db20e9e147a709e1f5dfe948d431112bd8 /gcc | |
parent | e36ee1b4df7197b6e7542bb67004b1fcf09714ce (diff) | |
download | gcc-56adf813f4e23d95d92385dee9b31e5e0d476abd.zip gcc-56adf813f4e23d95d92385dee9b31e5e0d476abd.tar.gz gcc-56adf813f4e23d95d92385dee9b31e5e0d476abd.tar.bz2 |
[Ada] No_Implicit_Loops restriction and pragma Assert
gcc/ada/
* tbuild.adb (Make_Implicit_Loop_Statement): Disable restriction
checking on dead paths.
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ada/tbuild.adb | 43 |
1 files changed, 36 insertions, 7 deletions
diff --git a/gcc/ada/tbuild.adb b/gcc/ada/tbuild.adb index 3b33ee7..6febaa7 100644 --- a/gcc/ada/tbuild.adb +++ b/gcc/ada/tbuild.adb @@ -35,6 +35,7 @@ with Opt; use Opt; 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; @@ -348,14 +349,42 @@ package body Tbuild is 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), |