p16.cpp 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. // RUN: %clang_cc1 -std=c++11 %s -Wunused -Wno-unused-lambda-capture -verify
  2. struct X {
  3. X(const X&) = delete; // expected-note 2{{explicitly marked deleted}}
  4. X(X&);
  5. };
  6. void test_capture(X x) {
  7. [x] { }(); // okay: non-const copy ctor
  8. [x] {
  9. [x] { // expected-error{{call to deleted constructor of 'X'}}
  10. }();
  11. }();
  12. [x] {
  13. [&x] {
  14. [x] { // expected-error{{call to deleted constructor of 'const X'}}
  15. }();
  16. }();
  17. }();
  18. int a;
  19. [=] {
  20. [&] {
  21. int &x = a; // expected-error{{binding reference of type 'int' to value of type 'const int' drops 'const' qualifier}}
  22. int &x2 = a; // expected-error{{binding reference of type 'int' to value of type 'const int' drops 'const' qualifier}}
  23. }();
  24. }();
  25. [=] {
  26. [&a] {
  27. [&] {
  28. int &x = a; // expected-error{{binding reference of type 'int' to value of type 'const int' drops 'const' qualifier}}
  29. int &x2 = a; // expected-error{{binding reference of type 'int' to value of type 'const int' drops 'const' qualifier}}
  30. }();
  31. }();
  32. }();
  33. }