OSDN Git Service

* gcc-interface/utils2.c (gnat_build_constructor): Test the TREE_STATIC
authorebotcazou <ebotcazou@138bc75d-0d04-0410-961f-82ee72b054a4>
Sun, 11 Dec 2011 11:05:58 +0000 (11:05 +0000)
committerebotcazou <ebotcazou@138bc75d-0d04-0410-961f-82ee72b054a4>
Sun, 11 Dec 2011 11:05:58 +0000 (11:05 +0000)
flag of elements to compute that of the constructor.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@182203 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ada/ChangeLog
gcc/ada/gcc-interface/utils2.c
gcc/testsuite/ChangeLog
gcc/testsuite/gnat.dg/specs/elab3.ads [new file with mode: 0644]

index 6a2dd26..6adbc2a 100644 (file)
@@ -1,5 +1,10 @@
 2011-12-11  Eric Botcazou  <ebotcazou@adacore.com>
 
+       * gcc-interface/utils2.c (gnat_build_constructor): Test the TREE_STATIC
+       flag of elements to compute that of the constructor.
+
+2011-12-11  Eric Botcazou  <ebotcazou@adacore.com>
+
        * gcc-interface/decl.c (gnat_to_gnu_param): Set the restrict qualifier
        on references built for parameters which aren't specifically by-ref.
 
index f9e48b7..93663b4 100644 (file)
@@ -1817,7 +1817,7 @@ gnat_build_constructor (tree type, VEC(constructor_elt,gc) *v)
   FOR_EACH_CONSTRUCTOR_ELT (v, n_elmts, obj, val)
     {
       /* The predicate must be in keeping with output_constructor.  */
-      if (!TREE_CONSTANT (val)
+      if ((!TREE_CONSTANT (val) && !TREE_STATIC (val))
          || (TREE_CODE (type) == RECORD_TYPE
              && CONSTRUCTOR_BITFIELD_P (obj)
              && !initializer_constant_valid_for_bitfield_p (val))
index 41e3b40..cfb9a61 100644 (file)
@@ -1,3 +1,7 @@
+2011-12-11  Eric Botcazou  <ebotcazou@adacore.com>
+
+       * gnat.dg/specs/elab3.ads: New test.
+
 2011-12-10  Richard Henderson  <rth@redhat.com>
 
        * gcc.target/powerpc/altivec-perm-1.c: New.
diff --git a/gcc/testsuite/gnat.dg/specs/elab3.ads b/gcc/testsuite/gnat.dg/specs/elab3.ads
new file mode 100644 (file)
index 0000000..7af6f38
--- /dev/null
@@ -0,0 +1,16 @@
+-- { dg-do compile }
+
+pragma Restrictions(No_Elaboration_Code);
+
+package Elab3 is
+
+   type T_List is array (Positive range <>) of Integer;
+   type T_List_Access is access constant T_List;
+
+   type R is record
+     A : T_List_Access;
+   end record;
+
+   C : constant R := (A => null);
+
+end Elab3;