+2011-04-08 Eric Botcazou <ebotcazou@adacore.com>
+
+ * gcc-interface/trans.c (Identifier_to_gnu): Do not return initializers
+ of aggregate types that contain a placeholder.
+
2011-04-08 Nathan Froyd <froydnj@codesourcery.com>
* gcc-interface/utils.c (handle_sentinel_attribute): Don't use
/* If we have a constant declaration and its initializer, try to return the
latter to avoid the need to call fold in lots of places and the need for
- elaboration code if this identifier is used as an initializer itself. */
+ elaboration code if this identifier is used as an initializer itself.
+ Don't do it for aggregate types that contain a placeholder since their
+ initializers cannot be manipulated easily. */
if (TREE_CONSTANT (gnu_result)
&& DECL_P (gnu_result)
- && DECL_INITIAL (gnu_result))
+ && DECL_INITIAL (gnu_result)
+ && !(AGGREGATE_TYPE_P (TREE_TYPE (gnu_result))
+ && type_contains_placeholder_p (TREE_TYPE (gnu_result))))
{
bool constant_only = (TREE_CODE (gnu_result) == CONST_DECL
&& !DECL_CONST_CORRESPONDING_VAR (gnu_result));
+2011-04-08 Eric Botcazou <ebotcazou@adacore.com>
+
+ * gnat.dg/aggr17.adb: New test.
+ * gnat.dg/aggr18.adb: Likewise.
+
2011-04-08 Michael Matz <matz@suse.de>
PR middle-end/48389
--- /dev/null
+-- { dg-do compile }\r
+-- { dg-options "-gnatws" }\r
+\r
+procedure Aggr17 is\r
+\r
+ type Enum is (A, B);\r
+\r
+ type Rec (D : Enum := Enum'First) is record\r
+ case D is\r
+ when A => X : Integer;\r
+ when B => null;\r
+ end case;\r
+ end record;\r
+ for Rec'Size use 128;\r
+ pragma Volatile (Rec);\r
+\r
+ type Config_T (D : Enum := Enum'First) is record\r
+ N : Natural;\r
+ R : Rec (D);\r
+ end record;\r
+\r
+ C : constant Config_T := (D => A, N => 1, R => (D => A, X => 0));\r
+\r
+ type Arr is array (Natural range 1 .. C.N) of Boolean;\r
+\r
+begin\r
+ null;\r
+end;\r
--- /dev/null
+-- { dg-do compile }\r
+-- { dg-options "-gnatws" }\r
+\r
+procedure Aggr18 is\r
+\r
+ type Enum is (A, B);\r
+\r
+ type Rec (D : Enum := Enum'First) is record\r
+ case D is\r
+ when A => X : Integer;\r
+ when B => null;\r
+ end case;\r
+ end record;\r
+ for Rec'Size use 128;\r
+ pragma Volatile (Rec);\r
+\r
+ type Config_T (D : Enum := Enum'First) is record\r
+ N : Natural;\r
+ R : Rec (D);\r
+ end record;\r
+\r
+ C : Config_T := (D => A, N => 1, R => (D => A, X => 0));\r
+\r
+ type Arr is array (Natural range 1 .. C.N) of Boolean;\r
+\r
+begin\r
+ null;\r
+end;\r