From f8e7f3f3f33e22721a28772cc3f9b616e48cd1c9 Mon Sep 17 00:00:00 2001 From: Jason Merrill Date: Thu, 11 Feb 2021 22:01:19 -0500 Subject: cgraph: flatten and same_body aliases [PR96078] The patch for PR92372 made us start warning about a flatten attribute on an alias. But in the case of C++ 'tor base/complete variants, the user didn't create the alias. If the alias target also has the attribute, the alias points to a flattened function, so we shouldn't warn. gcc/ChangeLog: PR c++/96078 * cgraphunit.c (process_function_and_variable_attributes): Don't warn about flatten on an alias if the target also has it. * cgraph.h (symtab_node::get_alias_target_tree): New. gcc/testsuite/ChangeLog: PR c++/96078 * g++.dg/ext/attr-flatten1.C: New test. --- gcc/cgraph.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'gcc/cgraph.h') diff --git a/gcc/cgraph.h b/gcc/cgraph.h index 47b5c02..4a1f899 100644 --- a/gcc/cgraph.h +++ b/gcc/cgraph.h @@ -319,6 +319,9 @@ public: /* Return node that alias is aliasing. */ inline symtab_node *get_alias_target (void); + /* Return DECL that alias is aliasing. */ + inline tree get_alias_target_tree (); + /* Set section for symbol and its aliases. */ void set_section (const char *section); @@ -2665,6 +2668,17 @@ symtab_node::get_alias_target (void) return ref->referred; } +/* Return the DECL (or identifier) that alias is aliasing. Unlike the above, + this works whether or not the alias has been analyzed already. */ + +inline tree +symtab_node::get_alias_target_tree () +{ + if (alias_target) + return alias_target; + return get_alias_target ()->decl; +} + /* Return next reachable static symbol with initializer after the node. */ inline symtab_node * -- cgit v1.1