diff mbox

C++ PATCH for c++/63942 (mangling compat alias problems)

Message ID 54732981.3050606@redhat.com
State New
Headers show

Commit Message

Jason Merrill Nov. 24, 2014, 12:50 p.m. UTC
On 11/21/2014 04:32 PM, Jason Merrill wrote:
> In this testcase, the wrong old mangling for one constructor matches the
> correct mangling for the other constructor, and the testcase was failing
> to compile as a result.  But compatibility aliases should not be treated
> as conflicting with real declarations; they should be discarded.

We also need to avoid creating the alias declarations if they aren't 
going to become symbol aliases.

Tested x86_64-pc-linux-gnu, applying to trunk.
diff mbox

Patch

commit 58386ef80f1ab5d7ec49dc96b23e365e5750a3a0
Author: Jason Merrill <jason@redhat.com>
Date:   Sun Nov 23 22:23:44 2014 -0500

    	PR c++/63942
    	* mangle.c (mangle_decl): If we aren't going to create a symbol
    	alias, don't build the alias DECL either.

diff --git a/gcc/cp/mangle.c b/gcc/cp/mangle.c
index a244669..71a6e3b 100644
--- a/gcc/cp/mangle.c
+++ b/gcc/cp/mangle.c
@@ -3518,6 +3518,12 @@  mangle_decl (const tree decl)
       if (IDENTIFIER_GLOBAL_VALUE (id2))
 	return;
 
+      struct cgraph_node *n = NULL;
+      if (TREE_CODE (decl) == FUNCTION_DECL
+	  && !(n = cgraph_node::get (decl)))
+	/* Don't create an alias to an unreferenced function.  */
+	return;
+
       tree alias = make_alias_for (decl, id2);
       SET_IDENTIFIER_GLOBAL_VALUE (id2, alias);
       DECL_IGNORED_P (alias) = 1;
@@ -3526,11 +3532,7 @@  mangle_decl (const tree decl)
       if (vague_linkage_p (decl))
 	DECL_WEAK (alias) = 1;
       if (TREE_CODE (decl) == FUNCTION_DECL)
-	{
-	  /* Don't create an alias to an unreferenced function.  */
-	  if (struct cgraph_node *n = cgraph_node::get (decl))
-	    n->create_same_body_alias (alias, decl);
-	}
+	n->create_same_body_alias (alias, decl);
       else
 	varpool_node::create_extra_name_alias (alias, decl);
 #endif