diff mbox

[C++] PR 65811

Message ID 5589DC7F.6060207@oracle.com
State New
Headers show

Commit Message

Paolo Carlini June 23, 2015, 10:23 p.m. UTC
Hi,

the testcase shows that after Jason's r222134 in some cases it can still 
happen that TREE_PUBLIC is false and DECL_COMDAT is true, thus the 
assertion in vague_linkage_p triggers. For the testcase, in 
duplicate_decls, newdecl starts with both flags true and only the former 
becomes false when its value is copied from olddecl. Alternately to the 
simple tweak which I tested succesfully, I briefly wondered if we 
shouldn't just copy DECL_COMDAT too, in duplicate_decls, but that also 
causes the regression of ext/gnu-inline-global.C and 
ext/gnu-inline-namespace.C.

Thanks,
Paolo.

////////////////////
/cp
2015-06-23  Paolo Carlini  <paolo.carlini@oracle.com>

	PR c++/65811
	* decl.c (duplicate_decls): Adjust DECL_COMDAT of newdecl.

/testsuite
2015-06-23  Paolo Carlini  <paolo.carlini@oracle.com>

	PR c++/65811
	* g++.dg/other/linkage2.C: New.

Comments

Jason Merrill June 24, 2015, 3:31 a.m. UTC | #1
OK.

Jason
diff mbox

Patch

Index: cp/decl.c
===================================================================
--- cp/decl.c	(revision 224854)
+++ cp/decl.c	(working copy)
@@ -2106,6 +2106,8 @@  duplicate_decls (tree newdecl, tree olddecl, bool
   TREE_STATIC (olddecl) = TREE_STATIC (newdecl) |= TREE_STATIC (olddecl);
   if (! DECL_EXTERNAL (olddecl))
     DECL_EXTERNAL (newdecl) = 0;
+  if (! DECL_COMDAT (olddecl))
+    DECL_COMDAT (newdecl) = 0;
 
   new_template_info = NULL_TREE;
   if (DECL_LANG_SPECIFIC (newdecl) && DECL_LANG_SPECIFIC (olddecl))
Index: testsuite/g++.dg/other/linkage2.C
===================================================================
--- testsuite/g++.dg/other/linkage2.C	(revision 0)
+++ testsuite/g++.dg/other/linkage2.C	(working copy)
@@ -0,0 +1,10 @@ 
+// PR c++/65811
+
+struct foo { int i; };
+
+static void fn1 ();
+inline void
+fn1 ()
+{
+  static struct foo a[1];
+}