public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r12-1503] [Ada] Fix missing array bounds checking
@ 2021-06-16  8:44 Pierre-Marie de Rodat
  0 siblings, 0 replies; only message in thread
From: Pierre-Marie de Rodat @ 2021-06-16  8:44 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:1ac6fcf57c55ec2cac914b64d5d56a341a5aa4f0

commit r12-1503-g1ac6fcf57c55ec2cac914b64d5d56a341a5aa4f0
Author: Bob Duff <duff@adacore.com>
Date:   Tue Feb 23 15:50:21 2021 -0500

    [Ada] Fix missing array bounds checking
    
    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).

Diff:
---
 gcc/ada/ghost.adb | 18 ++++++++++++++----
 1 file changed, 14 insertions(+), 4 deletions(-)

diff --git a/gcc/ada/ghost.adb b/gcc/ada/ghost.adb
index f95bd19c504..42ea0f52cf3 100644
--- a/gcc/ada/ghost.adb
+++ b/gcc/ada/ghost.adb
@@ -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;


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-06-16  8:44 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-16  8:44 [gcc r12-1503] [Ada] Fix missing array bounds checking Pierre-Marie de Rodat

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).