p10.cpp 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. // RUN: %clang_cc1 -std=c++11 %s -verify
  2. int GlobalVar; // expected-note {{declared here}}
  3. namespace N {
  4. int AmbiguousVar; // expected-note {{candidate}}
  5. }
  6. int AmbiguousVar; // expected-note {{candidate}}
  7. using namespace N;
  8. class X0 {
  9. int Member;
  10. static void Overload(int);
  11. void Overload();
  12. virtual X0& Overload(float);
  13. void explicit_capture() {
  14. int variable; // expected-note {{declared here}}
  15. (void)[&Overload] () {}; // expected-error {{does not name a variable}}
  16. (void)[&GlobalVar] () {}; // expected-error {{does not have automatic storage duration}}
  17. (void)[&AmbiguousVar] () {}; // expected-error {{reference to 'AmbiguousVar' is ambiguous}}
  18. (void)[&Variable] () {}; // expected-error {{use of undeclared identifier 'Variable'; did you mean 'variable'}}
  19. }
  20. };
  21. void test_reaching_scope() {
  22. int local; // expected-note{{declared here}}
  23. static int local_static; // expected-note{{'local_static' declared here}}
  24. (void)[=]() {
  25. struct InnerLocal {
  26. void member() {
  27. (void)[local, // expected-error{{reference to local variable 'local' declared in enclosing function 'test_reaching_scope'}}
  28. local_static]() { // expected-error{{'local_static' cannot be captured because it does not have automatic storage duration}}
  29. return 0;
  30. };
  31. }
  32. };
  33. };
  34. }