https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94799
--- Comment #13 from Marek Polacek <mpolacek at gcc dot gnu.org> --- The fix may be as easy as this: --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -23812,8 +23812,8 @@ cp_parser_class_name (cp_parser *parser, /* Any name names a type if we're following the `typename' keyword in a qualified name where the enclosing scope is type-dependent. */ - typename_p = (typename_keyword_p && scope && TYPE_P (scope) - && dependent_type_p (scope)); + typename_p = (typename_keyword_p && parser->scope && TYPE_P (parser->scope) + && dependent_type_p (parser->scope)); /* Handle the common case (an identifier, but not a template-id) efficiently. */ if (token->type == CPP_NAME