diff --git a/clang/lib/Parse/Parser.cpp b/clang/lib/Parse/Parser.cpp index 6d0cf7b174e50e..71b87147e9a5f1 100644 --- a/clang/lib/Parse/Parser.cpp +++ b/clang/lib/Parse/Parser.cpp @@ -2060,9 +2060,19 @@ bool Parser::TryAnnotateTypeOrScopeToken( return true; } + bool TemplateKWPresent = false; + if (Tok.is(tok::kw_template)) { + ConsumeToken(); + TemplateKWPresent = true; + } + TypeResult Ty; if (Tok.is(tok::identifier)) { - // FIXME: check whether the next token is '<', first! + if (TemplateKWPresent && NextToken().isNot(tok::less)) { + Diag(Tok.getLocation(), + diag::missing_template_arg_list_after_template_kw); + return true; + } Ty = Actions.ActOnTypenameType(getCurScope(), TypenameLoc, SS, *Tok.getIdentifierInfo(), Tok.getLocation()); diff --git a/clang/test/Parser/cxx2a-concepts-requires-expr.cpp b/clang/test/Parser/cxx2a-concepts-requires-expr.cpp index 971591afb08dba..5755844a323d2c 100644 --- a/clang/test/Parser/cxx2a-concepts-requires-expr.cpp +++ b/clang/test/Parser/cxx2a-concepts-requires-expr.cpp @@ -83,7 +83,7 @@ bool r23 = requires { typename identity::temp; }; template bool r24 = requires { typename identity::template temp; - typename identity::template temp; // expected-error{{expected an identifier or template-id after '::'}} + typename identity::template temp; // expected-error{{template argument list is expected after a name prefixed by the template keyword}} }; bool r25 = requires { ; };