]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
[Ada] Improved support for aspect alignment in CCG
authorJavier Miranda <miranda@adacore.com>
Thu, 26 Dec 2019 20:29:24 +0000 (15:29 -0500)
committerPierre-Marie de Rodat <derodat@adacore.com>
Tue, 2 Jun 2020 08:58:22 +0000 (04:58 -0400)
2020-06-02  Javier Miranda  <miranda@adacore.com>

gcc/ada/

* sem_ch3.adb (Analyze_Object_Declaration): Set attribute
Expansion_Delayed on aggregates that initialize an object that
has aspect alignment or address clause. Done to allow ther
initialization by means of multiple assignments.
* exp_ch3.adb (Expand_N_Object_Declaration): Resolve delayed
aggregates. This patch complements the patch applied to
sem_ch3.adb

gcc/ada/exp_ch3.adb
gcc/ada/sem_ch3.adb

index 15d468be6c1c8285f2ca9d479224212e67f41369..cfc01f50ff6e22d13a6a273fc55e36c25a60316e 100644 (file)
@@ -6610,9 +6610,13 @@ package body Exp_Ch3 is
             --  An aggregate that must be built in place is not resolved and
             --  expanded until the enclosing construct is expanded. This will
             --  happen when the aggregate is limited and the declared object
-            --  has a following address clause.
+            --  has a following address clause; it happens also when generating
+            --  C code for an aggregate that has an alignment or address clause
+            --  (see Analyze_Object_Declaration).
 
-            if Is_Limited_Type (Typ) and then not Analyzed (Expr) then
+            if (Is_Limited_Type (Typ) or else Modify_Tree_For_C)
+              and then not Analyzed (Expr)
+            then
                Resolve (Expr, Typ);
             end if;
 
index c57be77a46c8d382bd5e55e542629ed497b601ff..1479e34f765186c25cc1931cba1d833514fff9b0 100644 (file)
@@ -4318,7 +4318,11 @@ package body Sem_Ch3 is
             --  If the aggregate is limited it will be built in place, and its
             --  expansion is deferred until the object declaration is expanded.
 
-            if Is_Limited_Type (T) then
+            --  This is also required when generating C code to ensure that an
+            --  object with an alignment or address clause can be initialized
+            --  by means of component by component assignments.
+
+            if Is_Limited_Type (T) or else Modify_Tree_For_C then
                Set_Expansion_Delayed (E);
             end if;