diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst --- a/clang/docs/ReleaseNotes.rst +++ b/clang/docs/ReleaseNotes.rst @@ -167,8 +167,8 @@ (C++14 [dcl.constexpr]p6 (CWG DR647/CWG DR1358)) - Correctly defer dependent immediate function invocations until template instantiation. This fixes `GH55601 `_. - - +- Class member variables are now in scope when parsing requires clauses. Fixes + `GH55216 `_. C++2b Feature Support ^^^^^^^^^^^^^^^^^^^^^ diff --git a/clang/lib/Parse/ParseTemplate.cpp b/clang/lib/Parse/ParseTemplate.cpp --- a/clang/lib/Parse/ParseTemplate.cpp +++ b/clang/lib/Parse/ParseTemplate.cpp @@ -289,8 +289,14 @@ LateParsedAttrList LateParsedAttrs(true); if (DeclaratorInfo.isFunctionDeclarator()) { - if (Tok.is(tok::kw_requires)) + if (Tok.is(tok::kw_requires)) { + CXXScopeSpec ScopeSpec = DeclaratorInfo.getCXXScopeSpec(); + DeclaratorScopeObj DeclScopeObj(*this, ScopeSpec); + if (ScopeSpec.isValid() && + Actions.ShouldEnterDeclaratorScope(getCurScope(), ScopeSpec)) + DeclScopeObj.EnterDeclaratorScope(); ParseTrailingRequiresClause(DeclaratorInfo); + } MaybeParseGNUAttributes(DeclaratorInfo, &LateParsedAttrs); } diff --git a/clang/test/Parser/cxx-concepts-requires-clause.cpp b/clang/test/Parser/cxx-concepts-requires-clause.cpp --- a/clang/test/Parser/cxx-concepts-requires-clause.cpp +++ b/clang/test/Parser/cxx-concepts-requires-clause.cpp @@ -12,6 +12,7 @@ struct AA; enum E : int; static int x; + static constexpr int z = 16; template requires true void Mfoo(); @@ -24,6 +25,8 @@ template requires true using MQ = M; + + constexpr int bazz() requires (z == 16); }; template requires (!0) @@ -56,6 +59,9 @@ template requires true using Q = A; +template requires (!0) +constexpr int A::bazz() requires (z == 16) { return z; } + struct C { template requires true void Mfoo();