public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r12-1591] [Ada] Fix detection of valid renamings for overlapping checks
@ 2021-06-17 14:34 Pierre-Marie de Rodat
  0 siblings, 0 replies; only message in thread
From: Pierre-Marie de Rodat @ 2021-06-17 14:34 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:aeafd222d4c132efee8f7b47a48cc1c7b5a0b4c9

commit r12-1591-gaeafd222d4c132efee8f7b47a48cc1c7b5a0b4c9
Author: Piotr Trojanek <trojanek@adacore.com>
Date:   Wed Mar 10 23:40:13 2021 +0100

    [Ada] Fix detection of valid renamings for overlapping checks
    
    gcc/ada/
    
            * sem_util.adb (Is_Valid_Renaming): Check not only indexed
            components, but slices too.

Diff:
---
 gcc/ada/sem_util.adb | 30 ++++++++++++++++++++++++++++++
 1 file changed, 30 insertions(+)

diff --git a/gcc/ada/sem_util.adb b/gcc/ada/sem_util.adb
index 855195dd220..b71efde8567 100644
--- a/gcc/ada/sem_util.adb
+++ b/gcc/ada/sem_util.adb
@@ -7301,6 +7301,9 @@ package body Sem_Util is
             return False;
          end if;
 
+         --  Check if any expression within the renamed object_name contains no
+         --  references to variables nor calls on nonstatic functions.
+
          if Nkind (N) = N_Indexed_Component then
             declare
                Indx : Node_Id;
@@ -7315,6 +7318,33 @@ package body Sem_Util is
                   Next_Index (Indx);
                end loop;
             end;
+
+         elsif Nkind (N) = N_Slice then
+            declare
+               Rng : constant Node_Id := Discrete_Range (N);
+            begin
+               --  Bounds specified as a range
+
+               if Nkind (Rng) = N_Range then
+                  if not Is_OK_Static_Range (Rng) then
+                     return False;
+                  end if;
+
+               --  Bounds specified as a constrained subtype indication
+
+               elsif Nkind (Rng) = N_Subtype_Indication then
+                  if not Is_OK_Static_Range
+                       (Range_Expression (Constraint (Rng)))
+                  then
+                     return False;
+                  end if;
+
+               --  Bounds specified as a subtype name
+
+               elsif not Is_OK_Static_Expression (Rng) then
+                  return False;
+               end if;
+            end;
          end if;
 
          if Has_Prefix (N) then


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

only message in thread, other threads:[~2021-06-17 14:34 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-17 14:34 [gcc r12-1591] [Ada] Fix detection of valid renamings for overlapping checks 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).