]> gcc.gnu.org Git - gcc.git/commitdiff
trans.c (Identifier_to_gnu): Do not return initializers of aggregate types that conta...
authorEric Botcazou <ebotcazou@adacore.com>
Fri, 8 Apr 2011 20:21:36 +0000 (20:21 +0000)
committerEric Botcazou <ebotcazou@gcc.gnu.org>
Fri, 8 Apr 2011 20:21:36 +0000 (20:21 +0000)
* gcc-interface/trans.c (Identifier_to_gnu): Do not return initializers
of aggregate types that contain a placeholder.

From-SVN: r172209

gcc/ada/ChangeLog
gcc/ada/gcc-interface/trans.c
gcc/testsuite/ChangeLog
gcc/testsuite/gnat.dg/aggr17.adb [new file with mode: 0644]
gcc/testsuite/gnat.dg/aggr18.adb [new file with mode: 0644]

index 155256e068cee43f69880f5be58279c6c89d5d1e..2046aa715d98ecd6b38eef51fbb9a951eba5eccb 100644 (file)
@@ -1,3 +1,8 @@
+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
index 9622625a7ec2cca05dfa333c281b7334831ed7a5..378f88c604d35c611a1c5d44ac8399cd3f1bd207 100644 (file)
@@ -1058,10 +1058,14 @@ Identifier_to_gnu (Node_Id gnat_node, tree *gnu_result_type_p)
 
   /* 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));
index 4f5fb0006dbb74c8612a9ecd343ba01f4b91d51a..23f95b16e40a907410fbaa978a716c491983f829 100644 (file)
@@ -1,3 +1,8 @@
+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
diff --git a/gcc/testsuite/gnat.dg/aggr17.adb b/gcc/testsuite/gnat.dg/aggr17.adb
new file mode 100644 (file)
index 0000000..3ba4198
--- /dev/null
@@ -0,0 +1,28 @@
+-- { 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
diff --git a/gcc/testsuite/gnat.dg/aggr18.adb b/gcc/testsuite/gnat.dg/aggr18.adb
new file mode 100644 (file)
index 0000000..511add8
--- /dev/null
@@ -0,0 +1,28 @@
+-- { 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
This page took 0.078919 seconds and 5 git commands to generate.