luken-google created this revision.
Herald added a project: All.
luken-google requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Fixes issue #55216.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D132503

Files:
  clang/lib/Parse/ParseTemplate.cpp
  clang/test/Parser/cxx-concepts-requires-clause.cpp


Index: clang/test/Parser/cxx-concepts-requires-clause.cpp
===================================================================
--- clang/test/Parser/cxx-concepts-requires-clause.cpp
+++ 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 <typename> requires true
   void Mfoo();
@@ -24,6 +25,8 @@
 
   template <typename TT> requires true
   using MQ = M<TT>;
+
+  constexpr int bazz() requires (z == 16);
 };
 
 template <typename T> requires (!0)
@@ -56,6 +59,9 @@
 template <typename T> requires true
 using Q = A<T>;
 
+template<typename T> requires (!0)
+constexpr int A<T>::bazz() requires (z == 16) { return z; }
+
 struct C {
   template <typename> requires true
   void Mfoo();
Index: clang/lib/Parse/ParseTemplate.cpp
===================================================================
--- clang/lib/Parse/ParseTemplate.cpp
+++ clang/lib/Parse/ParseTemplate.cpp
@@ -289,8 +289,15 @@
 
   LateParsedAttrList LateParsedAttrs(true);
   if (DeclaratorInfo.isFunctionDeclarator()) {
-    if (Tok.is(tok::kw_requires))
+    if (Tok.is(tok::kw_requires)) {
+      DeclaratorScopeObj DeclScopeObj(*this, DeclaratorInfo.getCXXScopeSpec());
+      if (DeclaratorInfo.getCXXScopeSpec().isValid()) {
+        if (Actions.ShouldEnterDeclaratorScope(getCurScope(), 
DeclaratorInfo.getCXXScopeSpec())) {
+          DeclScopeObj.EnterDeclaratorScope();
+        }
+      }
       ParseTrailingRequiresClause(DeclaratorInfo);
+    }
 
     MaybeParseGNUAttributes(DeclaratorInfo, &LateParsedAttrs);
   }


Index: clang/test/Parser/cxx-concepts-requires-clause.cpp
===================================================================
--- clang/test/Parser/cxx-concepts-requires-clause.cpp
+++ 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 <typename> requires true
   void Mfoo();
@@ -24,6 +25,8 @@
 
   template <typename TT> requires true
   using MQ = M<TT>;
+
+  constexpr int bazz() requires (z == 16);
 };
 
 template <typename T> requires (!0)
@@ -56,6 +59,9 @@
 template <typename T> requires true
 using Q = A<T>;
 
+template<typename T> requires (!0)
+constexpr int A<T>::bazz() requires (z == 16) { return z; }
+
 struct C {
   template <typename> requires true
   void Mfoo();
Index: clang/lib/Parse/ParseTemplate.cpp
===================================================================
--- clang/lib/Parse/ParseTemplate.cpp
+++ clang/lib/Parse/ParseTemplate.cpp
@@ -289,8 +289,15 @@
 
   LateParsedAttrList LateParsedAttrs(true);
   if (DeclaratorInfo.isFunctionDeclarator()) {
-    if (Tok.is(tok::kw_requires))
+    if (Tok.is(tok::kw_requires)) {
+      DeclaratorScopeObj DeclScopeObj(*this, DeclaratorInfo.getCXXScopeSpec());
+      if (DeclaratorInfo.getCXXScopeSpec().isValid()) {
+        if (Actions.ShouldEnterDeclaratorScope(getCurScope(), DeclaratorInfo.getCXXScopeSpec())) {
+          DeclScopeObj.EnterDeclaratorScope();
+        }
+      }
       ParseTrailingRequiresClause(DeclaratorInfo);
+    }
 
     MaybeParseGNUAttributes(DeclaratorInfo, &LateParsedAttrs);
   }
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to