[clang] [Clang] Added Regression test for #176710 (PR #249241)

Kingsley Leon via cfe-commits cfe-commits at lists.llvm.org
Sat Dec 5 06:54:01 PST 2026


https://github.com/goostty created https://github.com/llvm/llvm-project/pull/249241

**Summary**

* Added a regression test in
SemaCXX/cxx2b-consteval-propagate.cpp to verify correct diagnostic propagation of
immediate functions inside lambda templates

**Testing**

* bin/llvm-lit -sv ../clang/test/SemaCXX/cxx2b-consteval-propagate.cpp (ran in build directory, 1/1 passed)

>From ed339515069aa7910245ad5989d70703afddf6f4 Mon Sep 17 00:00:00 2001
From: Kingsley Leon <kingsleyl.dev at gmail.com>
Date: Sat, 5 Dec 2026 09:35:37 -0500
Subject: [PATCH] Regression test for #176710

**Summary**

Added a regression test in
SemaCXX/cxx2b-consteval-propagate.cpp

**Testing**

* bin/llvm-lit -sv ../clang/test/SemaCXX/cxx2b-consteval-propagate.cpp
  (ran in build directory, 1/1 passed)

Signed-off-by: Kingsley Leon <kingsleyl.dev at gmail.com>
---
 .../SemaCXX/cxx2b-consteval-propagate.cpp     | 24 +++++++++++++++++++
 1 file changed, 24 insertions(+)

diff --git a/clang/test/SemaCXX/cxx2b-consteval-propagate.cpp b/clang/test/SemaCXX/cxx2b-consteval-propagate.cpp
index 52ab5252b87809..4705e00beb945b 100644
--- a/clang/test/SemaCXX/cxx2b-consteval-propagate.cpp
+++ b/clang/test/SemaCXX/cxx2b-consteval-propagate.cpp
@@ -724,3 +724,27 @@ void test() {
                                  // ok, (outer) call to a (non-immediate) function template instantiation
 }
 }
+
+namespace GH176710 {
+  consteval void trigger_defect(); // expected-note {{declared here}}
+
+  template < int > struct C {
+    public:
+      static void f() {
+        auto lambda = [](auto &&obj) -> decltype(0) { // expected-note {{'operator()<int>' defined here}}
+          trigger_defect(); // expected-note {{undefined function 'trigger_defect' cannot be used in a constant expression}}
+                            // expected-note at -1 {{'operator()<int>' is an immediate function because its body contains a call to a consteval function 'trigger_defect' and that call is not a constant expression}}
+                            // expected-note at -2 {{'operator()<int>' is an immediate function because its body contains a call to a consteval function 'trigger_defect' and that call is not a constant expression}}
+        };
+        lambda(0); // expected-error {{immediate function 'operator()<int>' used before it is defined}}
+                   // expected-error at -1 {{call to immediate function 'GH176710::C<1>::f()::(lambda)::operator()<int>' is not a constant expression}}
+                   // expected-note at -2 {{in call to 'lambda.operator()<int>(0)'}}
+                   // expected-note at -3 {{in instantiation of function template specialization 'GH176710::C<1>::f()::(lambda)::operator()<int>' requested here}}
+      }
+  };
+  
+  int main() {
+    C<1>::f(); // expected-note {{in instantiation of member function 'GH176710::C<1>::f' requested here}}
+               // expected-note at -1 {{in instantiation of member function 'GH176710::C<1>::f' requested here}}
+  }
+} // namespace GH176710



More information about the cfe-commits mailing list