+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
+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
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 *);
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);
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
{
/* 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;
}
+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
--- /dev/null
+inline int
+f (int x)
+{
+ static union
+ {
+ int i;
+ };
+ int j = i;
+ i = x;
+ return j;
+}
--- /dev/null
+// 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);
+}
--- /dev/null
+#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;
+}
--- /dev/null
+template<typename T>
+T
+f (T x)
+{
+ static union
+ {
+ T i;
+ };
+ T j = i;
+ i = x;
+ return j;
+}
--- /dev/null
+// 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);
+}
--- /dev/null
+#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;
+}
--- /dev/null
+static int
+f (int x)
+{
+ static union
+ {
+ int i;
+ };
+ int j = i;
+ i = x;
+ return j;
+}
--- /dev/null
+// 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);
+}
--- /dev/null
+#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;
+}
/* 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);