https://github.com/zyn0217 updated 
https://github.com/llvm/llvm-project/pull/149121

>From 83f0655ef86a4ec09053f5beeced4440d4a46039 Mon Sep 17 00:00:00 2001
From: Dan Katz <[email protected]>
Date: Wed, 16 Jul 2025 11:25:23 -0400
Subject: [PATCH] Don't mark lambda non-dependent if nested in a generic
 lambda.

Fixes #118187.
---
 clang/docs/ReleaseNotes.rst            |  1 +
 clang/lib/Sema/TreeTransform.h         |  2 ++
 clang/test/SemaCXX/cxx2a-consteval.cpp | 11 ++++++++++-
 3 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 970825c98fec1..4c902d2ab6d83 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -963,6 +963,7 @@ Bug Fixes to C++ Support
 - Fix a crash with NTTP when instantiating local class.
 - Fixed a crash involving list-initialization of an empty class with a
   non-empty initializer list. (#GH147949)
+- Fixed spurious diagnoses of certain nested lambda expressions. (#GH149121)
 
 Bug Fixes to AST Handling
 ^^^^^^^^^^^^^^^^^^^^^^^^^
diff --git a/clang/lib/Sema/TreeTransform.h b/clang/lib/Sema/TreeTransform.h
index 758012f894a41..5f2b93680cc3d 100644
--- a/clang/lib/Sema/TreeTransform.h
+++ b/clang/lib/Sema/TreeTransform.h
@@ -15512,6 +15512,8 @@ TreeTransform<Derived>::TransformLambdaExpr(LambdaExpr 
*E) {
     DC = DC->getParent();
   if ((getSema().isUnevaluatedContext() ||
        getSema().isConstantEvaluatedContext()) &&
+      !(dyn_cast_or_null<CXXRecordDecl>(DC->getParent()) &&
+        cast<CXXRecordDecl>(DC->getParent())->isGenericLambda()) &&
       (DC->isFileContext() || !DC->getParent()->isDependentContext()))
     DependencyKind = CXXRecordDecl::LDK_NeverDependent;
 
diff --git a/clang/test/SemaCXX/cxx2a-consteval.cpp 
b/clang/test/SemaCXX/cxx2a-consteval.cpp
index 1474c48cda3c1..d92529b465c6f 100644
--- a/clang/test/SemaCXX/cxx2a-consteval.cpp
+++ b/clang/test/SemaCXX/cxx2a-consteval.cpp
@@ -1319,6 +1319,15 @@ namespace GH139160{
   B result = (B){10, get_value(make_struct())}; // expected-error 
{{initializer element is not a compile-time constant}} 
                                                 // expected-error@-1 {{call to 
consteval function 'GH139160::get_value' is not a constant expression}}
                                                 // expected-note@-2  
{{non-constexpr function 'make_struct' cannot be used in a constant expression}}
-};
+}  // namespace GH139160
+
+namespace GH118187 {
 
+template <typename T> int t() {
+  return []<typename U> consteval {
+    return [](U v) { return v; }(123);
+  }.template operator()<int>();
+}
 
+int v = t<int>();
+}  // namespace GH118187

_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to