2012-02-11 07:38:02 +08:00
|
|
|
// RUN: %clang_cc1 -std=c++11 %s -Wunused -verify
|
|
|
|
|
|
|
|
|
|
|
|
struct X {
|
2012-02-18 17:37:24 +08:00
|
|
|
X(const X&) = delete; // expected-note 2{{explicitly marked deleted}}
|
2012-02-11 07:38:02 +08:00
|
|
|
X(X&);
|
|
|
|
};
|
|
|
|
|
|
|
|
void test_capture(X x) {
|
|
|
|
[x] { }(); // okay: non-const copy ctor
|
|
|
|
|
|
|
|
[x] {
|
2012-02-18 17:37:24 +08:00
|
|
|
[x] { // expected-error{{call to deleted constructor of 'X'}}
|
|
|
|
}();
|
|
|
|
}();
|
|
|
|
|
|
|
|
[x] {
|
|
|
|
[&x] {
|
|
|
|
[x] { // expected-error{{call to deleted constructor of 'const X'}}
|
|
|
|
}();
|
2012-02-11 07:38:02 +08:00
|
|
|
}();
|
|
|
|
}();
|
2012-02-18 13:51:20 +08:00
|
|
|
|
|
|
|
int a;
|
2012-02-18 17:37:24 +08:00
|
|
|
[=]{
|
|
|
|
[&] {
|
2015-05-16 09:27:03 +08:00
|
|
|
int &x = a; // expected-error{{binding value of type 'const int' to reference of type 'int' drops 'const' qualifier}}
|
|
|
|
int &x2 = a; // expected-error{{binding value of type 'const int' to reference of type 'int' drops 'const' qualifier}}
|
2012-02-18 17:37:24 +08:00
|
|
|
}();
|
|
|
|
}();
|
|
|
|
|
|
|
|
[=]{
|
|
|
|
[&a] {
|
|
|
|
[&] {
|
2015-05-16 09:27:03 +08:00
|
|
|
int &x = a; // expected-error{{binding value of type 'const int' to reference of type 'int' drops 'const' qualifier}}
|
|
|
|
int &x2 = a; // expected-error{{binding value of type 'const int' to reference of type 'int' drops 'const' qualifier}}
|
2012-02-18 17:37:24 +08:00
|
|
|
}();
|
|
|
|
}();
|
|
|
|
}();
|
2012-02-11 07:38:02 +08:00
|
|
|
}
|