[multiple changes]
authorArnaud Charlet <charlet@gcc.gnu.org>
Tue, 2 May 2017 08:18:17 +0000 (10:18 +0200)
committerArnaud Charlet <charlet@gcc.gnu.org>
Tue, 2 May 2017 08:18:17 +0000 (10:18 +0200)
2017-05-02  Eric Botcazou  <ebotcazou@adacore.com>

* freeze.adb (Check_Component_Storage_Order): Do not treat bit-packed
array components specially.

2017-05-02  Ed Schonberg  <schonberg@adacore.com>

* sem_ch8.adb (Premature_Usage): If the premature usage of
an entity is as the expression in its own object decaration,
rewrite the reference as Any_Id to prevent cascaded errors or
compiler loops when such an entity is used in an address clause.

From-SVN: r247462

gcc/ada/ChangeLog
gcc/ada/freeze.adb
gcc/ada/sem_ch8.adb

index 3c7dd63..daf086f 100644 (file)
@@ -1,3 +1,15 @@
+2017-05-02  Eric Botcazou  <ebotcazou@adacore.com>
+
+       * freeze.adb (Check_Component_Storage_Order): Do not treat bit-packed
+       array components specially.
+
+2017-05-02  Ed Schonberg  <schonberg@adacore.com>
+
+       * sem_ch8.adb (Premature_Usage): If the premature usage of
+       an entity is as the expression in its own object decaration,
+       rewrite the reference as Any_Id to prevent cascaded errors or
+       compiler loops when such an entity is used in an address clause.
+
 2017-05-01  Eric Botcazou  <ebotcazou@adacore.com>
 
        * gcc-interface/decl.c (components_to_record): Add missing guard.
index 9c48644..e072824 100644 (file)
@@ -1267,18 +1267,10 @@ package body Freeze is
 
             --  Component SSO differs from enclosing composite:
 
-            --  Reject if component is a bit-packed array, as it is represented
-            --  as a scalar internally.
-
-            if Is_Bit_Packed_Array (Comp_Base) then
-               Error_Msg_N
-                 ("type of packed component must have same scalar storage "
-                  & "order as enclosing composite", Err_Node);
-
             --  Reject if composite is a bit-packed array, as it is rewritten
             --  into an array of scalars.
 
-            elsif Is_Bit_Packed_Array (Encl_Base) then
+            if Is_Bit_Packed_Array (Encl_Base) then
                Error_Msg_N
                  ("type of packed array must have same scalar storage order "
                   & "as component", Err_Node);
index 03a21c2..f765bb8 100644 (file)
@@ -8562,6 +8562,14 @@ package body Sem_Ch8 is
       else
          Error_Msg_N
            ("object& cannot be used before end of its declaration!", N);
+
+         --  If the premature reference appears as the expression in its own
+         --  declaration, rewrite it to prevent compiler loops in subsequent
+         --  uses of this mangled declaration in address clauses.
+
+         if Nkind (Parent (N)) = N_Object_Declaration then
+            Set_Entity (N, Any_Id);
+         end if;
       end if;
    end Premature_Usage;