[clang] [Clang] Don't skip capture of parameters in default arguments (PR #235529)

Chen Miao via cfe-commits cfe-commits at lists.llvm.org
Tue Nov 3 15:46:06 PST 2026


================
@@ -0,0 +1,18 @@
+// RUN: %clang_cc1 -std=c++20 -fsyntax-only -verify %s
+
+int a(int g, int h = []{ return g; }()); // expected-error {{variable 'g' cannot be implicitly captured in a lambda with no capture-default specified}} expected-note {{'g' declared here}} expected-note {{lambda expression begins here}} expected-note {{capture 'g' by value}} expected-note {{capture 'g' by reference}} expected-note {{default capture by value}} expected-note {{default capture by reference}}
+
+int e(int g, int h = [] { int g = 1; return g; }());
+
+// Unevaluated operand in a trailing return type: still accepted.
+auto u(int g) -> decltype([] { return g; }());
----------------
ChenMiaoi wrote:

Why do u accepted this?

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


More information about the cfe-commits mailing list