Douglas Gregor | 53a9bdf | 2012-02-01 01:18:43 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -std=c++11 %s -verify |
| 2 | |
| 3 | class X0 { |
| 4 | void explicit_capture() { |
| 5 | int foo; |
| 6 | |
Douglas Gregor | 656bc62 | 2012-02-09 08:26:42 +0000 | [diff] [blame] | 7 | (void)[foo, foo] () {}; // expected-error {{'foo' can appear only once}} |
| 8 | (void)[this, this] () {}; // expected-error {{'this' can appear only once}} |
| 9 | (void)[=, foo] () {}; // expected-error {{'&' must precede a capture when}} |
| 10 | (void)[=, &foo] () {}; |
| 11 | (void)[=, this] () {}; // expected-error {{'this' cannot appear}} |
| 12 | (void)[&, foo] () {}; |
| 13 | (void)[&, &foo] () {}; // expected-error {{'&' cannot precede a capture when}} |
| 14 | (void)[&, this] () {}; |
Douglas Gregor | 53a9bdf | 2012-02-01 01:18:43 +0000 | [diff] [blame] | 15 | } |
| 16 | }; |
Douglas Gregor | 136b2f2 | 2012-02-10 09:37:05 +0000 | [diff] [blame^] | 17 | |
| 18 | struct S2 { void f(int i); }; |
| 19 | |
| 20 | void S2::f(int i) { |
| 21 | (void)[&, i]{ }; |
| 22 | (void)[&, &i]{ }; // expected-error{{'&' cannot precede a capture when the capture default is '&'}} |
| 23 | (void)[=, this]{ }; // expected-error{{'this' cannot appear in a capture list when the capture default is '='}} |
| 24 | (void)[i, i]{ }; // expected-error{{'i' can appear only once in a capture list}} |
| 25 | } |