OSDN Git Service

gcc/
authorhjl <hjl@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 19 Feb 2009 15:22:28 +0000 (15:22 +0000)
committerhjl <hjl@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 19 Feb 2009 15:22:28 +0000 (15:22 +0000)
2009-02-19  H.J. Lu  <hongjiu.lu@intel.com>

PR c++/39188
* varasm.c (assemble_variable): Don't check DECL_NAME when
globalizing a variable.

gcc/cp/

2009-02-19  H.J. Lu  <hongjiu.lu@intel.com>

PR c++/39188
* cp-tree.h (maybe_commonize_var): New.

* decl.c (maybe_commonize_var): Make it extern.

* decl2.c (finish_anon_union): Call maybe_commonize_var.

gcc/testsuite/

2009-02-19  H.J. Lu  <hongjiu.lu@intel.com>

PR c++/39188
* g++.dg/abi/pr39188-1a.C: New.
* g++.dg/abi/pr39188-1b.C: Likewise.
* g++.dg/abi/pr39188-1.h: Likewise.
* g++.dg/abi/pr39188-2a.C: Likewise.
* g++.dg/abi/pr39188-2b.C: Likewise.
* g++.dg/abi/pr39188-2.h: Likewise.
* g++.dg/abi/pr39188-3a.C: Likewise.
* g++.dg/abi/pr39188-3b.C: Likewise.
* g++.dg/abi/pr39188-3.h: Likewise.

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

16 files changed:
gcc/ChangeLog
gcc/cp/ChangeLog
gcc/cp/cp-tree.h
gcc/cp/decl.c
gcc/cp/decl2.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/abi/pr39188-1.h [new file with mode: 0644]
gcc/testsuite/g++.dg/abi/pr39188-1a.C [new file with mode: 0644]
gcc/testsuite/g++.dg/abi/pr39188-1b.C [new file with mode: 0644]
gcc/testsuite/g++.dg/abi/pr39188-2.h [new file with mode: 0644]
gcc/testsuite/g++.dg/abi/pr39188-2a.C [new file with mode: 0644]
gcc/testsuite/g++.dg/abi/pr39188-2b.C [new file with mode: 0644]
gcc/testsuite/g++.dg/abi/pr39188-3.h [new file with mode: 0644]
gcc/testsuite/g++.dg/abi/pr39188-3a.C [new file with mode: 0644]
gcc/testsuite/g++.dg/abi/pr39188-3b.C [new file with mode: 0644]
gcc/varasm.c

index da214e8..84315ee 100644 (file)
@@ -1,3 +1,9 @@
+2009-02-19  H.J. Lu  <hongjiu.lu@intel.com>
+
+       PR c++/39188
+       * varasm.c (assemble_variable): Don't check DECL_NAME when
+       globalizing a variable.
+
 2009-02-19  Joseph Myers  <joseph@codesourcery.com>
 
        PR c/38483
index 709453d..c766c7f 100644 (file)
@@ -1,3 +1,12 @@
+2009-02-19  H.J. Lu  <hongjiu.lu@intel.com>
+
+       PR c++/39188
+       * cp-tree.h (maybe_commonize_var): New.
+
+       * decl.c (maybe_commonize_var): Make it extern.
+
+       * decl2.c (finish_anon_union): Call maybe_commonize_var.
+
 2009-02-18  H.J. Lu  <hongjiu.lu@intel.com>
 
        PR c++/39219
index b23a396..fa4017d 100644 (file)
@@ -4360,6 +4360,7 @@ extern tree finish_function                       (int);
 extern tree start_method                       (cp_decl_specifier_seq *, const cp_declarator *, tree);
 extern tree finish_method                      (tree);
 extern void maybe_register_incomplete_var      (tree);
+extern void maybe_commonize_var                        (tree);
 extern void complete_vars                      (tree);
 extern void finish_stmt                                (void);
 extern void print_other_binding_stack          (struct cp_binding_level *);
index 8476959..930f944 100644 (file)
@@ -81,7 +81,6 @@ static tree lookup_and_check_tag (enum tag_types, tree, tag_scope, bool);
 static int walk_namespaces_r (tree, walk_namespaces_fn, void *);
 static void maybe_deduce_size_from_array_init (tree, tree);
 static void layout_var_decl (tree);
-static void maybe_commonize_var (tree);
 static tree check_initializer (tree, tree, int, tree *);
 static void make_rtl_for_nonlocal_decl (tree, tree, const char *);
 static void save_function_data (tree);
@@ -4536,7 +4535,7 @@ layout_var_decl (tree decl)
    we have a weak definition, we must endeavor to create only one
    instance of the variable at link-time.  */
 
-static void
+void
 maybe_commonize_var (tree decl)
 {
   /* Static data in a function with comdat linkage also has comdat
index 2cafc83..9d33bbf 100644 (file)
@@ -1364,6 +1364,7 @@ finish_anon_union (tree anon_union_decl)
     {
       /* Use main_decl to set the mangled name.  */
       DECL_NAME (anon_union_decl) = DECL_NAME (main_decl);
+      maybe_commonize_var (anon_union_decl);
       mangle_decl (anon_union_decl);
       DECL_NAME (anon_union_decl) = NULL_TREE;
     }
index 2a4bad1..a84d1f6 100644 (file)
@@ -1,3 +1,16 @@
+2009-02-19  H.J. Lu  <hongjiu.lu@intel.com>
+
+       PR c++/39188
+       * g++.dg/abi/pr39188-1a.C: New.
+       * g++.dg/abi/pr39188-1b.C: Likewise.
+       * g++.dg/abi/pr39188-1.h: Likewise.
+       * g++.dg/abi/pr39188-2a.C: Likewise.
+       * g++.dg/abi/pr39188-2b.C: Likewise.
+       * g++.dg/abi/pr39188-2.h: Likewise.
+       * g++.dg/abi/pr39188-3a.C: Likewise.
+       * g++.dg/abi/pr39188-3b.C: Likewise.
+       * g++.dg/abi/pr39188-3.h: Likewise.
+
 2009-02-19  Joseph Myers  <joseph@codesourcery.com>
 
        PR c/38483
diff --git a/gcc/testsuite/g++.dg/abi/pr39188-1.h b/gcc/testsuite/g++.dg/abi/pr39188-1.h
new file mode 100644 (file)
index 0000000..ece67da
--- /dev/null
@@ -0,0 +1,11 @@
+inline int
+f (int x)
+{
+  static union 
+    {
+      int i;
+    };
+  int j = i;
+  i = x;
+  return j;
+}
diff --git a/gcc/testsuite/g++.dg/abi/pr39188-1a.C b/gcc/testsuite/g++.dg/abi/pr39188-1a.C
new file mode 100644 (file)
index 0000000..eb64669
--- /dev/null
@@ -0,0 +1,12 @@
+// PR c++/39188
+// { dg-do run }
+// { dg-options "-O2" }
+// { dg-additional-sources "pr39188-1b.C" }
+
+#include "pr39188-1.h"
+
+int
+x (int i)
+{
+  return f (i);
+}
diff --git a/gcc/testsuite/g++.dg/abi/pr39188-1b.C b/gcc/testsuite/g++.dg/abi/pr39188-1b.C
new file mode 100644 (file)
index 0000000..71c9926
--- /dev/null
@@ -0,0 +1,15 @@
+#include "pr39188-1.h"
+
+extern "C" void abort ();
+
+extern int x (int);
+
+int
+main (void)
+{
+  if (x (1) != 0)
+    abort ();
+  if (f (1) != 1)
+    abort ();
+  return 0;
+}
diff --git a/gcc/testsuite/g++.dg/abi/pr39188-2.h b/gcc/testsuite/g++.dg/abi/pr39188-2.h
new file mode 100644 (file)
index 0000000..6ff5f49
--- /dev/null
@@ -0,0 +1,12 @@
+template<typename T>
+T
+f (T x)
+{
+  static union 
+    {
+      T i;
+    };
+  T j = i;
+  i = x;
+  return j;
+}
diff --git a/gcc/testsuite/g++.dg/abi/pr39188-2a.C b/gcc/testsuite/g++.dg/abi/pr39188-2a.C
new file mode 100644 (file)
index 0000000..071b585
--- /dev/null
@@ -0,0 +1,12 @@
+// PR c++/39188
+// { dg-do run }
+// { dg-options "-O2" }
+// { dg-additional-sources "pr39188-2b.C" }
+
+#include "pr39188-2.h"
+
+int
+x (int i)
+{
+  return f<int> (i);
+}
diff --git a/gcc/testsuite/g++.dg/abi/pr39188-2b.C b/gcc/testsuite/g++.dg/abi/pr39188-2b.C
new file mode 100644 (file)
index 0000000..f91367b
--- /dev/null
@@ -0,0 +1,15 @@
+#include "pr39188-2.h"
+
+extern "C" void abort ();
+
+extern int x (int);
+
+int
+main (void)
+{
+  if (x (1) != 0)
+    abort ();
+  if (f<int> (1) != 1)
+    abort ();
+  return 0;
+}
diff --git a/gcc/testsuite/g++.dg/abi/pr39188-3.h b/gcc/testsuite/g++.dg/abi/pr39188-3.h
new file mode 100644 (file)
index 0000000..e0c9f61
--- /dev/null
@@ -0,0 +1,11 @@
+static int
+f (int x)
+{
+  static union 
+    {
+      int i;
+    };
+  int j = i;
+  i = x;
+  return j;
+}
diff --git a/gcc/testsuite/g++.dg/abi/pr39188-3a.C b/gcc/testsuite/g++.dg/abi/pr39188-3a.C
new file mode 100644 (file)
index 0000000..5596d12
--- /dev/null
@@ -0,0 +1,12 @@
+// PR c++/39188
+// { dg-do run }
+// { dg-options "-O2" }
+// { dg-additional-sources "pr39188-3b.C" }
+
+#include "pr39188-3.h"
+
+int
+x (int i)
+{
+  return f (i);
+}
diff --git a/gcc/testsuite/g++.dg/abi/pr39188-3b.C b/gcc/testsuite/g++.dg/abi/pr39188-3b.C
new file mode 100644 (file)
index 0000000..84db157
--- /dev/null
@@ -0,0 +1,15 @@
+#include "pr39188-3.h"
+
+extern "C" void abort ();
+
+extern int x (int);
+
+int
+main (void)
+{
+  if (x (1) != 0)
+    abort ();
+  if (f (1) != 0)
+    abort ();
+  return 0;
+}
index 7fed300..49bbe06 100644 (file)
@@ -2161,7 +2161,6 @@ assemble_variable (tree decl, int top_level ATTRIBUTE_UNUSED,
   /* First make the assembler name(s) global if appropriate.  */
   sect = get_variable_section (decl, false);
   if (TREE_PUBLIC (decl)
-      && DECL_NAME (decl)
       && (sect->common.flags & SECTION_COMMON) == 0)
     globalize_decl (decl);