c++: lambda mangling alias issues [PR107897]
commita23b33a1bdeff7bc2289d9ebb7cb7b7ec0a605f5
authorJason Merrill <jason@redhat.com>
Mon, 6 Mar 2023 20:33:45 +0000 (6 15:33 -0500)
committerJason Merrill <jason@redhat.com>
Thu, 30 Mar 2023 11:23:03 +0000 (30 07:23 -0400)
tree4f51903b45adbda5e35a27168a8cb0216308953f
parent04b0a7b1a6d9e0f3782888f1ebf187c26690038b
c++: lambda mangling alias issues [PR107897]

In 107897, by the time we are looking at the mangling clash, the
alias has already been removed from the symbol table by analyze_functions,
so we can't look at n->cpp_implicit_alias.  So just assume that it's an
alias if it's internal.

In 108887 the problem is that removing the mangling alias from the symbol
table confuses analyze_functions, because it ended up as first_analyzed
somehow, so it becomes a dangling pointer.  So instead we call reset()
to neutralize the alias.  To make this work for variables, I needed to move
reset() from cgraph_node to symtab_node.

PR c++/107897
PR c++/108887

gcc/ChangeLog:

* cgraph.h: Move reset() from cgraph_node to symtab_node.
* cgraphunit.cc (symtab_node::reset): Adjust.  Also call
remove_from_same_comdat_group.

gcc/cp/ChangeLog:

* decl2.cc (record_mangling): Use symtab_node::reset.

gcc/testsuite/ChangeLog:

* g++.dg/cpp2a/concepts-lambda3.C: Use -flto if supported.
* g++.dg/cpp0x/lambda/lambda-mangle7.C: New test.
gcc/cgraph.h
gcc/cgraphunit.cc
gcc/cp/decl2.cc
gcc/testsuite/g++.dg/cpp0x/lambda/lambda-mangle7.C [new file with mode: 0644]
gcc/testsuite/g++.dg/cpp2a/concepts-lambda3.C