diff --git a/clang/lib/Parse/ParseDecl.cpp b/clang/lib/Parse/ParseDecl.cpp index 09d1732739b8e..17298dad45640 100644 --- a/clang/lib/Parse/ParseDecl.cpp +++ b/clang/lib/Parse/ParseDecl.cpp @@ -3407,7 +3407,7 @@ void Parser::ParseDeclarationSpecifiers(DeclSpec &DS, if (!TypeRep) { if (TryAnnotateTypeConstraint()) goto DoneWithDeclSpec; - if (isTypeConstraintAnnotation()) + if (Tok.isNot(tok::identifier)) continue; if (Tok.is(tok::annot_template_id)) // Might have been annotated by TryAnnotateTypeConstraint. diff --git a/clang/test/SemaTemplate/undeclared-template.cpp b/clang/test/SemaTemplate/undeclared-template.cpp new file mode 100644 index 0000000000000..fccc29deea254 --- /dev/null +++ b/clang/test/SemaTemplate/undeclared-template.cpp @@ -0,0 +1,9 @@ +// RUN: %clang_cc1 -std=c++2a -verify %s + +template notdefined PR45207; // expected-error {{no template named 'notdefined'}} + +// FIXME: We don't disambiguate this as an undeclared template-id even though there's nothing else it could be. +template int var_template(notdefined); // expected-error {{undeclared identifier 'notdefined'}} expected-error {{expected expression}} + +// FIXME: We don't disambiguate this as a function template even though it can't be a variable template due to the ', int'. +template int fn_template(notdefined, int); // expected-error {{undeclared identifier 'notdefined'}} expected-error {{expected expression}} expected-error {{expected '('}}