[Ada] Issue with unnesting of 'First/Last and renaming
authorRichard Kenner <kenner@adacore.com>
Mon, 17 Feb 2020 23:17:58 +0000 (18:17 -0500)
committerPierre-Marie de Rodat <derodat@adacore.com>
Mon, 8 Jun 2020 07:51:06 +0000 (03:51 -0400)
2020-06-08  Richard Kenner  <kenner@adacore.com>

gcc/ada/

* exp_unst.adb (Visit_Node): When visiting array attribute
nodes, in addition to checking the type of Get_Referenced_Object
of the prefix, also check the actual type of the prefix.

gcc/ada/exp_unst.adb

index ade5fe0cfacd18d4368a5ca60ae6c1915afc2c43..953d449bbc93d0b800872097b8c0a78587748bf6 100644 (file)
@@ -1049,22 +1049,27 @@ package body Exp_Unst is
                            --  from the (possibly) uplevel reference. We call
                            --  Get_Referenced_Object to deal with prefixes that
                            --  are object renamings (prefixes that are types
-                           --  can be passed and will simply be returned).
+                           --  can be passed and will simply be returned).  But
+                           --  it's also legal to get the bounds from the type
+                           --  of the prefix, so we have to handle both cases.
 
-                           if Is_Constrained
+                           declare
+                              DT : Boolean := False;
+
+                           begin
+                              if Is_Constrained
                                 (Etype (Get_Referenced_Object (Prefix (N))))
-                           then
-                              declare
-                                 DT : Boolean := False;
-                              begin
+                              then
                                  Check_Static_Type
                                    (Etype (Get_Referenced_Object (Prefix (N))),
-                                    Empty,
-                                    DT);
-                              end;
+                                    Empty, DT);
+                              end if;
 
-                              return OK;
-                           end if;
+                              if Is_Constrained (Etype (Prefix (N))) then
+                                 Check_Static_Type
+                                   (Etype (Prefix (N)), Empty, DT);
+                              end if;
+                           end;
 
                         when others =>
                            null;