diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst index 2ee946af32bf1..8d2b60dd75acf 100644 --- a/clang/docs/ReleaseNotes.rst +++ b/clang/docs/ReleaseNotes.rst @@ -790,6 +790,9 @@ Bug Fixes to C++ Support completes (except deduction guides). Fixes: (`#59827 `_) +- Fix crash when parsing nested requirement. Fixes: + (`#73112 `_) + Bug Fixes to AST Handling ^^^^^^^^^^^^^^^^^^^^^^^^^ - Fixed an import failure of recursive friend class template. diff --git a/clang/lib/Parse/ParseExprCXX.cpp b/clang/lib/Parse/ParseExprCXX.cpp index 79db094e098f8..8b86db1bb8fc5 100644 --- a/clang/lib/Parse/ParseExprCXX.cpp +++ b/clang/lib/Parse/ParseExprCXX.cpp @@ -3635,10 +3635,12 @@ ExprResult Parser::ParseRequiresExpression() { auto Res = TryParseParameterDeclarationClause(); if (Res != TPResult::False) { // Skip to the closing parenthesis - // FIXME: Don't traverse these tokens twice (here and in - // TryParseParameterDeclarationClause). unsigned Depth = 1; while (Depth != 0) { + bool FoundParen = SkipUntil(tok::l_paren, tok::r_paren, + SkipUntilFlags::StopBeforeMatch); + if (!FoundParen) + break; if (Tok.is(tok::l_paren)) Depth++; else if (Tok.is(tok::r_paren)) diff --git a/clang/test/Parser/cxx2a-concepts-requires-expr.cpp b/clang/test/Parser/cxx2a-concepts-requires-expr.cpp index a18a54c7fad06..971591afb08db 100644 --- a/clang/test/Parser/cxx2a-concepts-requires-expr.cpp +++ b/clang/test/Parser/cxx2a-concepts-requires-expr.cpp @@ -160,3 +160,11 @@ template requires requires { typename BitInt; // ok } using r44 = void; + +namespace GH73112 { +void f() { + requires { requires(int; } // expected-error {{expected ')'}} \ + // expected-error {{expected expression}} \ + // expected-note {{to match this '('}} +} +}