aboutsummaryrefslogtreecommitdiff
path: root/gcc/cgraphunit.c
diff options
context:
space:
mode:
authorJason Merrill <jason@redhat.com>2021-02-11 22:01:19 -0500
committerJason Merrill <jason@redhat.com>2021-03-02 23:20:43 -0500
commitf8e7f3f3f33e22721a28772cc3f9b616e48cd1c9 (patch)
tree93dc6074a803b49d2badf428cce3d7e4a8e5378f /gcc/cgraphunit.c
parent9b2084db9f9917eb9b19b1eb5ec03cdcb05f349e (diff)
downloadgcc-f8e7f3f3f33e22721a28772cc3f9b616e48cd1c9.zip
gcc-f8e7f3f3f33e22721a28772cc3f9b616e48cd1c9.tar.gz
gcc-f8e7f3f3f33e22721a28772cc3f9b616e48cd1c9.tar.bz2
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.
Diffstat (limited to 'gcc/cgraphunit.c')
-rw-r--r--gcc/cgraphunit.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/gcc/cgraphunit.c b/gcc/cgraphunit.c
index b401f08..1c74cee 100644
--- a/gcc/cgraphunit.c
+++ b/gcc/cgraphunit.c
@@ -859,8 +859,11 @@ process_function_and_variable_attributes (cgraph_node *first,
if (node->alias
&& lookup_attribute ("flatten", DECL_ATTRIBUTES (decl)))
{
- warning_at (DECL_SOURCE_LOCATION (node->decl), OPT_Wattributes,
- "%<flatten%> attribute is ignored on aliases");
+ tree tdecl = node->get_alias_target_tree ();
+ if (!tdecl || !DECL_P (tdecl)
+ || !lookup_attribute ("flatten", DECL_ATTRIBUTES (tdecl)))
+ warning_at (DECL_SOURCE_LOCATION (decl), OPT_Wattributes,
+ "%<flatten%> attribute is ignored on aliases");
}
if (DECL_PRESERVE_P (decl))
node->mark_force_output ();