https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103749
--- Comment #2 from Marek Polacek <mpolacek at gcc dot gnu.org> --- Same case: template<typename> struct bar; struct bar { int baz; }; bar var; Maybe xref_tag could detect this. The other way round it's a bit better: struct bar; template<typename> struct bar {}; bar var; 103749-2.C:11:8: error: ‘bar’ is not a template 11 | struct bar {}; | ^~~ 103749-2.C:8:8: note: previous declaration here 8 | struct bar; | ^~~