Skip to content
Snippets Groups Projects
Commit 6c282c14 authored by Jakub Jelinek's avatar Jakub Jelinek
Browse files

c++: Propagate attributes to clones in duplicate_decls [PR67453]

On the following testcase where the cdtor attributes aren't on the
in-class declaration but on an out-of-class definition, the cdtors
have their clones created from the in-class declaration, and later on
duplicate_decls updates attributes on the abstract cdtors, but nothing
propagates them to the clones.

2020-11-06  Jakub Jelinek  <jakub@redhat.com>

	PR c++/67453
	* decl.c (duplicate_decls): Propagate DECL_ATTRIBUTES and
	DECL_PRESERVE_P from olddecl to its clones if any.

	* g++.dg/ext/attr-used-2.C: New test.
parent 556ab512
No related branches found
No related tags found
No related merge requests found
...@@ -2921,6 +2921,16 @@ duplicate_decls (tree newdecl, tree olddecl, bool hiding, bool was_hidden) ...@@ -2921,6 +2921,16 @@ duplicate_decls (tree newdecl, tree olddecl, bool hiding, bool was_hidden)
snode->remove (); snode->remove ();
} }
   
if (TREE_CODE (olddecl) == FUNCTION_DECL)
{
tree clone;
FOR_EACH_CLONE (clone, olddecl)
{
DECL_ATTRIBUTES (clone) = DECL_ATTRIBUTES (olddecl);
DECL_PRESERVE_P (clone) |= DECL_PRESERVE_P (olddecl);
}
}
/* Remove the associated constraints for newdecl, if any, before /* Remove the associated constraints for newdecl, if any, before
reclaiming memory. */ reclaiming memory. */
if (flag_concepts) if (flag_concepts)
......
// PR c++/67453
// { dg-do compile }
// { dg-final { scan-assembler "_ZN1SC\[12]Ev" } }
// { dg-final { scan-assembler "_ZN1SD\[12]Ev" } }
// { dg-final { scan-assembler "_ZN1SC\[12]ERKS_" } }
struct S {
S();
~S();
S(const S&);
};
__attribute__((used)) inline S::S() { }
__attribute__((used)) inline S::~S() { }
__attribute__((used)) inline S::S(const S&) { }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment