https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89341
--- Comment #4 from David Malcolm <dmalcolm at gcc dot gnu.org> --- The -Wattributes warning would be emitted here in cgraphunit.c: process_function_and_variable_attributes: 777 if (lookup_attribute ("weakref", DECL_ATTRIBUTES (decl)) 778 && (node->definition && !node->alias)) 779 { 780 warning_at (DECL_SOURCE_LOCATION (node->decl), OPT_Wattributes, 781 "%<weakref%> attribute ignored" 782 " because function is defined"); 783 DECL_WEAK (decl) = 0; 784 DECL_ATTRIBUTES (decl) = remove_attribute ("weakref", 785 DECL_ATTRIBUTES (decl)); 786 } but the alias stops the clause from firing: (gdb) p node $3 = <cgraph_node * 0x7ffff18af2d0 "foo"/0> (gdb) p node->definition $4 = 1 (gdb) p node->alias $5 = 1 The alias exclusion was added to the warning in r174952 (aka c70f46b057cd12973d33c01c8fa0da5c14ba3944) by Honza: @@ -880,7 +977,7 @@ process_function_and_variable_attributes (struct cgraph_node *first, cgraph_mark_needed_node (node); } if (lookup_attribute ("weakref", DECL_ATTRIBUTES (decl)) - && node->local.finalized) + && (node->local.finalized && !node->alias)) { warning_at (DECL_SOURCE_LOCATION (node->decl), OPT_Wattributes, "%<weakref%> attribute ignored"