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

>From 438c36861938991d1e8d750dea448e79d5d41813 Mon Sep 17 00:00:00 2001
From: Dan Katz <[email protected]>
Date: Wed, 16 Jul 2025 11:25:23 -0400
Subject: [PATCH 1/3] 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 63930f43c25e3..a0599f667fd9e 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -557,6 +557,7 @@ Bug Fixes to C++ Support
 - Diagnose unresolved overload sets in non-dependent compound requirements. 
(#GH51246) (#GH97753)
 - Fix a crash when extracting unavailable member type from alias in template 
deduction. (#GH165560)
 - Fix incorrect diagnostics for lambdas with init-captures inside braced 
initializers. (#GH163498)
+- 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 c2491489f40d2..0e8b674a006d0 100644
--- a/clang/lib/Sema/TreeTransform.h
+++ b/clang/lib/Sema/TreeTransform.h
@@ -15628,6 +15628,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..ca28d48f5366e 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

>From 17a98f9711e5ea7bc14d8d63069b77363d90445b Mon Sep 17 00:00:00 2001
From: Dan Katz <[email protected]>
Date: Sat, 22 Nov 2025 10:15:25 -0500
Subject: [PATCH 2/3] Adding test from #156579.

---
 clang/test/SemaCXX/cxx2a-consteval.cpp | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/clang/test/SemaCXX/cxx2a-consteval.cpp 
b/clang/test/SemaCXX/cxx2a-consteval.cpp
index ca28d48f5366e..92bfa40caec4e 100644
--- a/clang/test/SemaCXX/cxx2a-consteval.cpp
+++ b/clang/test/SemaCXX/cxx2a-consteval.cpp
@@ -1331,3 +1331,15 @@ template <typename T> int t() {
 
 int v = t<int>();
 }  // namespace GH118187
+
+namespace GH156579 {
+template <class>
+auto f{[] (auto...) {
+    if constexpr ([] (auto) { return true; }(0))
+        return 0;
+}};
+
+void g() {
+    f<int>();
+}
+}  // namespace GH156579

>From cbd6475f5d54516f018f367a43f689b181261bf5 Mon Sep 17 00:00:00 2001
From: Dan Katz <[email protected]>
Date: Sat, 22 Nov 2025 11:00:39 -0500
Subject: [PATCH 3/3] Add other issue.

---
 clang/docs/ReleaseNotes.rst | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index a0599f667fd9e..8161ccdffca82 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -557,7 +557,7 @@ Bug Fixes to C++ Support
 - Diagnose unresolved overload sets in non-dependent compound requirements. 
(#GH51246) (#GH97753)
 - Fix a crash when extracting unavailable member type from alias in template 
deduction. (#GH165560)
 - Fix incorrect diagnostics for lambdas with init-captures inside braced 
initializers. (#GH163498)
-- Fixed spurious diagnoses of certain nested lambda expressions. (#GH149121)
+- Fixed spurious diagnoses of certain nested lambda expressions. (#GH149121) 
(#GH156579)
 
 Bug Fixes to AST Handling
 ^^^^^^^^^^^^^^^^^^^^^^^^^

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

Reply via email to