https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105725
--- Comment #6 from CVS Commits <cvs-commit at gcc dot gnu.org> --- The releases/gcc-11 branch has been updated by Richard Biener <rgue...@gcc.gnu.org>: https://gcc.gnu.org/g:bd0c76a2329e7fe6d6612c2259647bbb67f5866a commit r11-10332-gbd0c76a2329e7fe6d6612c2259647bbb67f5866a Author: Marek Polacek <pola...@redhat.com> Date: Fri May 27 10:51:30 2022 -0400 c++: Fix ICE with -Wmismatched-tags [PR105725] Here we ICE with -Wmismatched-tags on something like template <class T> bool B<T, enable_if_t<is_class_v<class T::foo>>>; Specifically, the "class T::foo" bit. There, class_decl_loc_t::add gets a TYPENAME_TYPE as TYPE, rather than a class/union type, so checking TYPE_BEING_DEFINED will crash. I think it's OK to allow a TYPENAME_TYPE to slip into that function; we just shouldn't consider the 'class' tag redundant (which works as a 'typename'). In fact, every other compiler *requires* it. PR c++/105725 gcc/cp/ChangeLog: * parser.c (class_decl_loc_t::add): Check CLASS_TYPE_P. gcc/testsuite/ChangeLog: * g++.dg/warn/Wmismatched-tags-10.C: New test. (cherry picked from commit d822f4bbd714c6595f70cc68888dcebecfb6662d)