https://gcc.gnu.org/bugzilla/show_bug.cgi?id=56100
Paolo Carlini <paolo.carlini at oracle dot com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |jason at gcc dot gnu.org, | |paolo.carlini at oracle dot com --- Comment #3 from Paolo Carlini <paolo.carlini at oracle dot com> --- I wonder if in such cases would it simply make sense to suppress the warning basing on the locations, eg the below certainly works for the testcase and passes testing: Index: name-lookup.c =================================================================== --- name-lookup.c (revision 221789) +++ name-lookup.c (working copy) @@ -1271,7 +1271,9 @@ pushdecl_maybe_friend_1 (tree x, bool is_friend) } } else if (oldglobal != NULL_TREE - && (VAR_P (oldglobal) + && ((VAR_P (oldglobal) + && (input_location + > DECL_SOURCE_LOCATION (oldglobal))) /* If the old decl is a type decl, only warn if the old decl is an explicit typedef or if both the old and new decls are type decls. */