[clang] Suppress printing lambda body for constexpr diagnostics (PR #185800)

Sherman Pay via cfe-commits cfe-commits at lists.llvm.org
Thu Apr 9 16:18:14 PDT 2026


================
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -fsyntax-only -std=c++17 -verify=expected %s 
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -fsyntax-only -std=c++17 -verify=expected %s -fexperimental-new-constant-interpreter
+constexpr void undefined();  // expected-note {{declared here}}
+static constexpr int r = [] { // expected-error {{constexpr variable 'r' must be initialized by a constant expression}} \
+                                 expected-note {{in call to '[] {}.operator()()'}}}
+  undefined();  // expected-note {{undefined function 'undefined' cannot be used in a constant expression}}
+  return 0;
+ }();
+
----------------
shermpay wrote:

I added more a couple more tests:

1. Nested lambdas
2. type error
3. assigning the lambda to a variable and invoking it later
4. calling a lambda with a parameter

https://github.com/llvm/llvm-project/pull/185800


More information about the cfe-commits mailing list