]> gcc.gnu.org Git - gcc.git/commitdiff
[Ada] Fix missing array bounds checking
authorBob Duff <duff@adacore.com>
Tue, 23 Feb 2021 20:50:21 +0000 (15:50 -0500)
committerPierre-Marie de Rodat <derodat@adacore.com>
Wed, 16 Jun 2021 08:42:59 +0000 (04:42 -0400)
gcc/ada/

* ghost.adb: Add another special case where full analysis is
needed. This bug is due to quirks in the way
Mark_And_Set_Ghost_Assignment works (it happens very early,
before name resolution is done).

gcc/ada/ghost.adb

index f95bd19c504584e1649eb52880dba36edcfb5f82..42ea0f52cf33964713afc8b52715043ab46654d5 100644 (file)
@@ -1245,11 +1245,21 @@ package body Ghost is
       --  processing them in that mode can lead to spurious errors.
 
       if Expander_Active then
+         --  Cases where full analysis is needed, involving array indexing
+         --  which would otherwise be missing array-bounds checks:
+
          if not Analyzed (Orig_Lhs)
-           and then Nkind (Orig_Lhs) = N_Indexed_Component
-           and then Nkind (Prefix (Orig_Lhs)) = N_Selected_Component
-           and then Nkind (Prefix (Prefix (Orig_Lhs))) =
-           N_Indexed_Component
+           and then
+             ((Nkind (Orig_Lhs) = N_Indexed_Component
+                and then Nkind (Prefix (Orig_Lhs)) = N_Selected_Component
+                and then Nkind (Prefix (Prefix (Orig_Lhs))) =
+                           N_Indexed_Component)
+              or else
+             (Nkind (Orig_Lhs) = N_Selected_Component
+              and then Nkind (Prefix (Orig_Lhs)) = N_Indexed_Component
+              and then Nkind (Prefix (Prefix (Orig_Lhs))) =
+                         N_Selected_Component
+              and then Nkind (Parent (N)) /= N_Loop_Statement))
          then
             Analyze (Orig_Lhs);
          end if;
This page took 0.061217 seconds and 5 git commands to generate.