re PR c++/21454 (const array doesn't live in the rodata section in C++)
authorJakub Jelinek <jakub@redhat.com>
Tue, 17 May 2005 06:51:48 +0000 (08:51 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Tue, 17 May 2005 06:51:48 +0000 (08:51 +0200)
PR c++/21454
* decl.c (maybe_deduce_size_from_array_init): Call
cp_apply_type_quals_to_decl after completing array type.

* g++.dg/opt/const4.C: New test.

From-SVN: r99817

gcc/cp/ChangeLog
gcc/cp/decl.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/opt/const4.C [new file with mode: 0644]

index 0a21f0a1979fef28221e9e0a2b7ba5c841e03dc8..d5a88e9d2dbd61c6f14abf5c644b95f56e37d201 100644 (file)
@@ -1,3 +1,9 @@
+2005-05-17  Jakub Jelinek  <jakub@redhat.com>
+
+       PR c++/21454
+       * decl.c (maybe_deduce_size_from_array_init): Call
+       cp_apply_type_quals_to_decl after completing array type.
+
 2005-05-16  Richard Henderson  <rth@redhat.com>
 
        * decl.c (build_library_fn_1): Move setting TREE_NOTHROW ...
index c110d9fc5ff73cfa51dadf5340187c66c936268e..ac7608b76c308b2161ef6b1b80a8137998a3c6df 100644 (file)
@@ -3939,6 +3939,8 @@ maybe_deduce_size_from_array_init (tree decl, tree init)
       if (failure == 3)
        error ("zero-size array %qD", decl);
 
+      cp_apply_type_quals_to_decl (cp_type_quals (TREE_TYPE (decl)), decl);
+
       layout_decl (decl, 0);
     }
 }
index 2428cf14f36585ddd69c581066454bd54deb9ec3..367947b929bb34ced3cd614dcbb54c46ccfa3b42 100644 (file)
@@ -1,5 +1,8 @@
 2005-05-17  Jakub Jelinek  <jakub@redhat.com>
 
+       PR c++/21454
+       * g++.dg/opt/const4.C: New test.
+
        PR middle-end/21492
        * g++.dg/opt/crossjump1.C: New test.
 
diff --git a/gcc/testsuite/g++.dg/opt/const4.C b/gcc/testsuite/g++.dg/opt/const4.C
new file mode 100644 (file)
index 0000000..883c24b
--- /dev/null
@@ -0,0 +1,9 @@
+// PR c++/21454
+// Test whether A is put into .rodata section on platforms
+// that have it.
+// { dg-do compile }
+
+const int a[] __attribute__ ((__used__)) = { 0, 1, 2, 3 };
+
+// The MMIX port always switches to the .data section at the end of a file.
+// { dg-final { scan-assembler-not "\\.data(?!\\.rel\\.ro)" { xfail powerpc*-*-aix* mmix-*-* } } }