Malcolm Parsons | 87a0362 | 2017-01-13 15:01:06 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -std=c++11 %s -Wunused -Wno-unused-lambda-capture -verify |
Douglas Gregor | 28be7c5 | 2012-02-10 23:38:02 +0000 | [diff] [blame] | 2 | |
| 3 | |
| 4 | struct X { |
Douglas Gregor | fdf598e | 2012-02-18 09:37:24 +0000 | [diff] [blame] | 5 | X(const X&) = delete; // expected-note 2{{explicitly marked deleted}} |
Douglas Gregor | 28be7c5 | 2012-02-10 23:38:02 +0000 | [diff] [blame] | 6 | X(X&); |
| 7 | }; |
| 8 | |
| 9 | void test_capture(X x) { |
| 10 | [x] { }(); // okay: non-const copy ctor |
| 11 | |
| 12 | [x] { |
Douglas Gregor | fdf598e | 2012-02-18 09:37:24 +0000 | [diff] [blame] | 13 | [x] { // expected-error{{call to deleted constructor of 'X'}} |
| 14 | }(); |
| 15 | }(); |
| 16 | |
| 17 | [x] { |
| 18 | [&x] { |
| 19 | [x] { // expected-error{{call to deleted constructor of 'const X'}} |
| 20 | }(); |
Douglas Gregor | 28be7c5 | 2012-02-10 23:38:02 +0000 | [diff] [blame] | 21 | }(); |
| 22 | }(); |
Douglas Gregor | 812d8f6 | 2012-02-18 05:51:20 +0000 | [diff] [blame] | 23 | |
| 24 | int a; |
Douglas Gregor | fdf598e | 2012-02-18 09:37:24 +0000 | [diff] [blame] | 25 | [=]{ |
| 26 | [&] { |
Richard Trieu | d396763 | 2015-05-16 01:39:39 +0000 | [diff] [blame] | 27 | int &x = a; // expected-error{{binding value of type 'const int' to reference to type 'int' drops 'const' qualifier}} |
| 28 | int &x2 = a; // expected-error{{binding value of type 'const int' to reference to type 'int' drops 'const' qualifier}} |
Douglas Gregor | fdf598e | 2012-02-18 09:37:24 +0000 | [diff] [blame] | 29 | }(); |
| 30 | }(); |
| 31 | |
| 32 | [=]{ |
| 33 | [&a] { |
| 34 | [&] { |
Richard Trieu | d396763 | 2015-05-16 01:39:39 +0000 | [diff] [blame] | 35 | int &x = a; // expected-error{{binding value of type 'const int' to reference to type 'int' drops 'const' qualifier}} |
| 36 | int &x2 = a; // expected-error{{binding value of type 'const int' to reference to type 'int' drops 'const' qualifier}} |
Douglas Gregor | fdf598e | 2012-02-18 09:37:24 +0000 | [diff] [blame] | 37 | }(); |
| 38 | }(); |
| 39 | }(); |
Douglas Gregor | 28be7c5 | 2012-02-10 23:38:02 +0000 | [diff] [blame] | 40 | } |