]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR c++/14804 ([unit-at-a-time] initializing const data with reinterpret_cast-ed...
authorRichard Henderson <rth@redhat.com>
Thu, 1 Apr 2004 21:48:06 +0000 (13:48 -0800)
committerRichard Henderson <rth@gcc.gnu.org>
Thu, 1 Apr 2004 21:48:06 +0000 (13:48 -0800)
        PR c++/14804
        * decl.c (cp_finish_decl): Preserve TREE_READONLY more often.
        * typeck2.c (split_nonconstant_init): Clear TREE_READONLY.

From-SVN: r80325

gcc/cp/ChangeLog
gcc/cp/decl.c
gcc/cp/typeck2.c

index b3398a064604eaaf5f38712aa9e1f7fa9bba5d86..02082405ab293d0e61f92e9ad6177e629b28cc2d 100644 (file)
@@ -1,3 +1,9 @@
+2004-04-01  Richard Henderson  <rth@redhat.com>
+
+        PR c++/14804
+        * decl.c (cp_finish_decl): Preserve TREE_READONLY more often.
+        * typeck2.c (split_nonconstant_init): Clear TREE_READONLY.
+
 2003-03-17  Matt Austern  <austern@apple.com>
 
        Backport:
index 902416d24df0a17183f715d69663c0abd42e0813..91ef96afb9ee0296d6b664df410b6b20f3cbcb55 100644 (file)
@@ -8887,16 +8887,17 @@ cp_finish_decl (decl, init, asmspec_tree, flags)
   if (TREE_CODE (decl) != FUNCTION_DECL)
     ttype = target_type (type);
 
-  if (! DECL_EXTERNAL (decl) && TREE_READONLY (decl)
-      && (TYPE_NEEDS_CONSTRUCTING (type) 
-         || TREE_CODE (type) == REFERENCE_TYPE))
-    {
-      /* Currently, GNU C++ puts constants in text space, making them
-        impossible to initialize.  In the future, one would hope for
-        an operating system which understood the difference between
-        initialization and the running of a program.  */
+  
+  /* Currently, GNU C++ puts constants in text space, making them
+     impossible to initialize.  In the future, one would hope for
+     an operating system which understood the difference between
+     initialization and the running of a program.  */
+  if (! DECL_EXTERNAL (decl) && TREE_READONLY (decl))
+    {
       was_readonly = 1;
-      TREE_READONLY (decl) = 0;
+      if (TYPE_NEEDS_CONSTRUCTING (type) 
+         || TREE_CODE (type) == REFERENCE_TYPE)
+       TREE_READONLY (decl) = 0;
     }
 
   if (TREE_CODE (decl) == FIELD_DECL && asmspec)
index d80463213a0f237e619ccc663834431cfb073adc..e4929275b918e98d1de72ca6709fecbab759d455 100644 (file)
@@ -391,6 +391,7 @@ split_nonconstant_init (tree dest, tree init)
       code = build1 (STMT_EXPR, void_type_node, code);
       TREE_SIDE_EFFECTS (code) = 1;
       DECL_INITIAL (dest) = init;
+      TREE_READONLY (dest) = 0;
     }
   else
     code = build (INIT_EXPR, TREE_TYPE (dest), dest, init);