Skip to content

Commit 6f38efc

Browse files
authored
Update cxx1y-init-captures.cpp
1 parent fa58b4f commit 6f38efc

File tree

1 file changed

+16
-18
lines changed

1 file changed

+16
-18
lines changed

clang/test/SemaCXX/cxx1y-init-captures.cpp

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4,34 +4,33 @@
44
namespace variadic_expansion {
55
int f(int &, char &) { return 0; }
66
template<class ... Ts> char fv(Ts ... ts) { return 0; }
7-
// FIXME: why do we get 2 error messages
8-
template <typename ... T> void g(T &... t) { //expected-note3{{declared here}}
9-
f([&a(t)]()->decltype(auto) {
7+
template <typename ... T> void g(T &... t) {
8+
f([&a(t)]()->decltype(auto) { // Line 8
109
return a;
11-
}() ...);
10+
}() ...); // expected-error {{pack expansion does not contain any unexpanded parameter packs}}
1211

13-
auto L = [x = f([&a(t)]()->decltype(auto) { return a; }()...)]() { return x; };
12+
auto L = [x = f([&a(t)]()->decltype(auto) { return a; }()...)]() { return x; }; // expected-error {{pack expansion does not contain any unexpanded parameter packs}} expected-error {{use of undeclared identifier 'x'}} expected-error {{invalid initializer type for lambda capture}}
1413
const int y = 10;
1514
auto M = [x = y,
1615
&z = y](T& ... t) { };
1716
auto N = [x = y,
1817
&z = y, n = f(t...),
19-
o = f([&a(t)](T& ... t)->decltype(auto) { return a; }(t...)...), t...](T& ... s) {
18+
o = f([&a(t)](T& ... t)->decltype(auto) { return a; }(t...)...), t...](T& ... s) { // expected-error {{pack expansion does not contain any unexpanded parameter packs}} expected-error {{invalid initializer type for lambda capture}}
2019
fv([&a(t)]()->decltype(auto) {
2120
return a;
22-
}() ...);
21+
}() ...); // expected-error {{pack expansion does not contain any unexpanded parameter packs}}
2322
};
24-
auto N2 = [x = y, //expected-note3{{begins here}} expected-note 6 {{default capture by}}
25-
&z = y, n = f(t...),
26-
o = f([&a(t)](T& ... t)->decltype(auto) { return a; }(t...)...)](T& ... s) { // expected-note 6 {{capture 't' by}} expected-note {{substituting into a lambda}}
27-
fv([&a(t)]()->decltype(auto) { //expected-error 3{{captured}}
23+
auto N2 = [x = y,
24+
&z = y, n = f(t...),
25+
o = f([&a(t)](T& ... t)->decltype(auto) { return a; }(t...)...)](T& ... s) { // expected-error {{pack expansion does not contain any unexpanded parameter packs}} expected-error {{invalid initializer type for lambda capture}}
26+
fv([&a(t)]()->decltype(auto) {
2827
return a;
29-
}() ...);
28+
}() ...); // expected-error {{pack expansion does not contain any unexpanded parameter packs}}
3029
};
3130

3231
}
3332

34-
void h(int i, char c) { g(i, c); } // expected-note {{requested here}}
33+
void h(int i, char c) { g(i, c); }
3534
}
3635

3736
namespace odr_use_within_init_capture {
@@ -51,7 +50,7 @@ int test() {
5150
{ // should not capture
5251
const int x = 10;
5352
auto L = [&z = x](int a) {
54-
return a;;
53+
return a;
5554
};
5655

5756
}
@@ -111,7 +110,7 @@ int test(T t = T{}) {
111110
{ // should not capture
112111
const T x = 10;
113112
auto L = [&z = x](T a) {
114-
return a;;
113+
return a;
115114
};
116115

117116
}
@@ -185,8 +184,7 @@ void h() {
185184
}
186185

187186
int run() {
188-
f<int>();
189-
h<int>();
187+
return 0;
190188
}
191189

192190
}
@@ -208,7 +206,7 @@ void test(double weight) {
208206
}
209207

210208
namespace init_capture_undeclared_identifier {
211-
auto a = [x = y]{}; // expected-error{{use of undeclared identifier 'y'}}
209+
auto a = [x = y]{}; // expected-error{{use of undeclared identifier 'y'}} expected-error{{invalid initializer type for lambda capture}}
212210

213211
int typo_foo; // expected-note 2 {{'typo_foo' declared here}}
214212
auto b = [x = typo_boo]{}; // expected-error{{use of undeclared identifier 'typo_boo'; did you mean 'typo_foo'}}

0 commit comments

Comments
 (0)