blob: 905192ff830b8e976df7b9ebaad85940362694b5 [file] [log] [blame]
Malcolm Parsons87a03622017-01-13 15:01:06 +00001// RUN: %clang_cc1 -std=c++11 %s -Wunused -Wno-unused-lambda-capture -verify
Douglas Gregor28be7c52012-02-10 23:38:02 +00002
3
4struct X {
Douglas Gregorfdf598e2012-02-18 09:37:24 +00005 X(const X&) = delete; // expected-note 2{{explicitly marked deleted}}
Douglas Gregor28be7c52012-02-10 23:38:02 +00006 X(X&);
7};
8
9void test_capture(X x) {
10 [x] { }(); // okay: non-const copy ctor
11
12 [x] {
Douglas Gregorfdf598e2012-02-18 09:37:24 +000013 [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 Gregor28be7c52012-02-10 23:38:02 +000021 }();
22 }();
Douglas Gregor812d8f62012-02-18 05:51:20 +000023
24 int a;
Douglas Gregorfdf598e2012-02-18 09:37:24 +000025 [=]{
26 [&] {
Richard Trieud3967632015-05-16 01:39:39 +000027 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 Gregorfdf598e2012-02-18 09:37:24 +000029 }();
30 }();
31
32 [=]{
33 [&a] {
34 [&] {
Richard Trieud3967632015-05-16 01:39:39 +000035 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 Gregorfdf598e2012-02-18 09:37:24 +000037 }();
38 }();
39 }();
Douglas Gregor28be7c52012-02-10 23:38:02 +000040}