diff --git a/clang/lib/Parse/ParseExprCXX.cpp b/clang/lib/Parse/ParseExprCXX.cpp index cd600c4247a72f..2d38891c723f83 100644 --- a/clang/lib/Parse/ParseExprCXX.cpp +++ b/clang/lib/Parse/ParseExprCXX.cpp @@ -3589,7 +3589,7 @@ ExprResult Parser::ParseRequiresExpression() { // We need to consume the typename to allow 'requires { typename a; }' SourceLocation TypenameKWLoc = ConsumeToken(); - if (TryAnnotateCXXScopeToken()) { + if (TryAnnotateOptionalCXXScopeToken()) { TPA.Commit(); SkipUntil(tok::semi, tok::r_brace, SkipUntilFlags::StopBeforeMatch); break; diff --git a/clang/test/Parser/cxx2a-concepts-requires-expr.cpp b/clang/test/Parser/cxx2a-concepts-requires-expr.cpp index d22f21b786f447..d3f46c163ffd84 100644 --- a/clang/test/Parser/cxx2a-concepts-requires-expr.cpp +++ b/clang/test/Parser/cxx2a-concepts-requires-expr.cpp @@ -144,3 +144,18 @@ bool r40 = requires { requires (int i) { i; }; }; bool r41 = requires { requires (); }; // expected-error@-1 {{expected expression}} + +bool r42 = requires { typename long; }; // expected-error {{expected a qualified name after 'typename'}} + +template +requires requires { + typename _BitInt(N); // expected-error {{expected a qualified name after 'typename'}} +} using r43 = void; + +template +using BitInt = _BitInt(N); + +template +requires requires { + typename BitInt; // ok +} using r44 = void;