================
@@ -97,3 +97,29 @@ void foo() {
 
 }
 #endif
+
+#if __cplusplus >= 202002L
+void GH107048() {
+  constexpr int x{};
+  const int y{};
+  auto b = []<int=x, int=y>{};
+  using A = decltype([]<int=x>{});
+
+  int z; // expected-note {{'z' declared here}}
+  auto c = []<int t=z>{
+    // expected-error@-1 {{no matching function for call to object of type}} \
+    // expected-error@-1 {{variable 'z' cannot be implicitly captured in a 
lambda with no capture-default specified}} \
+    // expected-note@-1 {{lambda expression begins here}} \
+    // expected-note@-1 4{{capture}} \
+    // expected-note@-1 {{candidate template ignored: substitution failure: 
reference to local variable 'z' declared in enclosing function}}
+    return t;
+  }();
+
+  struct S {};
+  constexpr S s;  // expected-note {{'s' declared here}}
+  auto class_type = []<S=s>{};
+  // expected-error@-1 {{variable 's' cannot be implicitly captured in a 
lambda with no capture-default specified}} \
+  // expected-note@-1 {{lambda expression begins here}} \
+  // expected-note@-1 4{{capture}}
----------------
shafik wrote:

Curious about these cases: https://godbolt.org/z/xWbWYfnf3

```cpp
struct S {};
constexpr S s; 

void f() {
  auto class_type = []<S=s>{};
}

void h() {
  static constexpr S s;
  auto class_type = []<S=s>{};
}

template <S=s>
void g() {}
```

https://github.com/llvm/llvm-project/pull/107073
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to