re PR c++/44059 (Static initializers executed more than once when using unique global...
authorJakub Jelinek <jakub@redhat.com>
Tue, 11 May 2010 18:14:19 +0000 (20:14 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Tue, 11 May 2010 18:14:19 +0000 (20:14 +0200)
PR c++/44059
* config/elfos.h (ASM_DECLARE_OBJECT_NAME): Use qnu_unique_object
even for DECL_ONE_ONLY DECL_ARTIFICIAL !TREE_READONLY decls.
* config/alpha/elf.h (ASM_DECLARE_OBJECT_NAME): Likewise.
* dwarf2asm.c (dw2_output_indirect_constant_1): Set TREE_READONLY
on DW.ref.* decls.

From-SVN: r159287

gcc/ChangeLog
gcc/config/alpha/elf.h
gcc/config/elfos.h
gcc/dwarf2asm.c

index 712b4371b43662e1e414ab9fdbf250931cfe19df..16f56b89d03785b60928c563e6aff07cd948a6d6 100644 (file)
@@ -1,5 +1,12 @@
 2010-05-11  Jakub Jelinek  <jakub@redhat.com>
 
+       PR c++/44059
+       * config/elfos.h (ASM_DECLARE_OBJECT_NAME): Use qnu_unique_object
+       even for DECL_ONE_ONLY DECL_ARTIFICIAL !TREE_READONLY decls.
+       * config/alpha/elf.h (ASM_DECLARE_OBJECT_NAME): Likewise.
+       * dwarf2asm.c (dw2_output_indirect_constant_1): Set TREE_READONLY
+       on DW.ref.* decls.
+
        PR c++/44062
        * c-parser.c (c_parser_expression): Mark LHS of a comma
        expression as read if it is a decl, handled component or
index d2bf732543d0dcf61ee425d764a0818d5e995cb7..57ab91e2f3cb0c7bfd56d553310d975241fef71d 100644 (file)
@@ -1,6 +1,6 @@
 /* Definitions of target machine for GNU compiler, for DEC Alpha w/ELF.
    Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2007, 2008,
-   2009 Free Software Foundation, Inc.
+   2009, 2010 Free Software Foundation, Inc.
    Contributed by Richard Henderson (rth@tamu.edu).
 
 This file is part of GCC.
@@ -284,10 +284,12 @@ do {                                                                      \
     HOST_WIDE_INT size;                                                        \
                                                                        \
     /* For template static data member instantiations or               \
-       inline fn local statics, use gnu_unique_object so that          \
-       they will be combined even under RTLD_LOCAL.  */                        \
-    if (USE_GNU_UNIQUE_OBJECT                                          \
-       && !DECL_ARTIFICIAL (DECL) && DECL_ONE_ONLY (DECL))             \
+       inline fn local statics and their guard variables, use          \
+       gnu_unique_object so that they will be combined even under      \
+       RTLD_LOCAL.  Don't use gnu_unique_object for typeinfo,          \
+       vtables and other read-only artificial decls.  */               \
+    if (USE_GNU_UNIQUE_OBJECT  && DECL_ONE_ONLY (DECL)                 \
+       && (!DECL_ARTIFICIAL (DECL) || !TREE_READONLY (DECL)))          \
       ASM_OUTPUT_TYPE_DIRECTIVE (FILE, NAME, "gnu_unique_object");     \
     else                                                               \
       ASM_OUTPUT_TYPE_DIRECTIVE (FILE, NAME, "object");                        \
index 56d7b408e5d9c79a3305552f0bec46933625f2f3..6818f6600fe2069dcf7878d357b1513c3eb9cbfb 100644 (file)
@@ -1,7 +1,7 @@
 /* elfos.h  --  operating system specific defines to be used when
    targeting GCC for some generic ELF system
    Copyright (C) 1991, 1994, 1995, 1999, 2000, 2001, 2002, 2003, 2004,
-   2007, 2009 Free Software Foundation, Inc.
+   2007, 2009, 2010 Free Software Foundation, Inc.
    Based on svr4.h contributed by Ron Guilmette (rfg@netcom.com).
 
 This file is part of GCC.
@@ -301,10 +301,12 @@ see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
       HOST_WIDE_INT size;                                              \
                                                                        \
       /* For template static data member instantiations or             \
-        inline fn local statics, use gnu_unique_object so that         \
-        they will be combined even under RTLD_LOCAL.  */               \
-      if (USE_GNU_UNIQUE_OBJECT                                                \
-         && !DECL_ARTIFICIAL (DECL) && DECL_ONE_ONLY (DECL))           \
+        inline fn local statics and their guard variables, use         \
+        gnu_unique_object so that they will be combined even under     \
+        RTLD_LOCAL.  Don't use gnu_unique_object for typeinfo,         \
+        vtables and other read-only artificial decls.  */              \
+      if (USE_GNU_UNIQUE_OBJECT && DECL_ONE_ONLY (DECL)                        \
+         && (!DECL_ARTIFICIAL (DECL) || !TREE_READONLY (DECL)))        \
        ASM_OUTPUT_TYPE_DIRECTIVE (FILE, NAME, "gnu_unique_object");    \
       else                                                             \
        ASM_OUTPUT_TYPE_DIRECTIVE (FILE, NAME, "object");               \
index 0770607c61558c5c4d2ed712b5146b42b49aea0d..516a26004f0b115a738cd1e18d49858987ef3bbb 100644 (file)
@@ -1,5 +1,5 @@
 /* Dwarf2 assembler output helper routines.
-   Copyright (C) 2001, 2002, 2003, 2004, 2005, 2007, 2008, 2009
+   Copyright (C) 2001, 2002, 2003, 2004, 2005, 2007, 2008, 2009, 2010
    Free Software Foundation, Inc.
 
 This file is part of GCC.
@@ -877,6 +877,7 @@ dw2_output_indirect_constant_1 (splay_tree_node node,
   DECL_ARTIFICIAL (decl) = 1;
   DECL_IGNORED_P (decl) = 1;
   DECL_INITIAL (decl) = decl;
+  TREE_READONLY (decl) = 1;
 
   if (TREE_PUBLIC (id))
     {