[clang] Implement lifetime analysis for lifetime_capture_by(X) (#115921)
[llvm-project.git] / clang / test / SemaCXX / lambda-invalid-capture.cpp
blob5be8c8c5078f2690f5142e6e1ec404959ffd9669
1 // RUN: %clang_cc1 -fsyntax-only -verify -std=c++03 -Wno-c++11-extensions %s
2 // RUN: %clang_cc1 -fsyntax-only -verify %s
3 // Don't crash.
5 struct g {
6 j; // expected-error {{a type specifier is required for all declarations}}
7 };
9 void captures_invalid_type() {
10 g child;
11 auto q = [child]{};
12 const int n = sizeof(q);
15 void captures_invalid_array_type() {
16 g child[100];
17 auto q = [child]{};
18 const int n = sizeof(q);
21 int pr43080(int i) { // expected-note {{declared here}}
22 return [] { // expected-note {{begins here}} expected-note 2 {{capture 'i' by}} expected-note 2 {{default capture by}}
23 return sizeof i <
24 i; // expected-error {{variable 'i' cannot be implicitly captured in a lambda with no capture-default specified}}
25 }();