Douglas Gregor | 53a9bdf | 2012-02-01 01:18:43 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -std=c++11 %s -verify |
| 2 | |
Douglas Gregor | 8c50e7c | 2012-02-09 00:47:04 +0000 | [diff] [blame] | 3 | int GlobalVar; // expected-note {{declared here}} |
Douglas Gregor | 53a9bdf | 2012-02-01 01:18:43 +0000 | [diff] [blame] | 4 | |
| 5 | namespace N { |
| 6 | int AmbiguousVar; // expected-note {{candidate}} |
| 7 | } |
| 8 | int AmbiguousVar; // expected-note {{candidate}} |
| 9 | using namespace N; |
| 10 | |
| 11 | class X0 { |
| 12 | int Member; |
| 13 | |
| 14 | static void Overload(int); |
| 15 | void Overload(); |
| 16 | virtual X0& Overload(float); |
| 17 | |
| 18 | void explicit_capture() { |
Douglas Gregor | 8c50e7c | 2012-02-09 00:47:04 +0000 | [diff] [blame] | 19 | int variable; // expected-note {{declared here}} |
Douglas Gregor | 656bc62 | 2012-02-09 08:26:42 +0000 | [diff] [blame] | 20 | (void)[&Overload] () {}; // expected-error {{does not name a variable}} |
| 21 | (void)[&GlobalVar] () {}; // expected-error {{does not have automatic storage duration}} |
| 22 | (void)[&AmbiguousVar] () {}; // expected-error {{reference to 'AmbiguousVar' is ambiguous}} |
| 23 | (void)[&Variable] () {}; // expected-error {{use of undeclared identifier 'Variable'; did you mean 'variable'}} |
Douglas Gregor | 53a9bdf | 2012-02-01 01:18:43 +0000 | [diff] [blame] | 24 | } |
| 25 | }; |
Douglas Gregor | f02455e | 2012-02-10 09:26:04 +0000 | [diff] [blame^] | 26 | |
| 27 | void test_reaching_scope() { |
| 28 | int local; // expected-note{{declared here}} |
| 29 | static int local_static; // expected-note{{'local_static' declared here}} |
| 30 | (void)[=]() { |
| 31 | struct InnerLocal { |
| 32 | void member() { |
| 33 | (void)[local, // expected-error{{reference to local variable 'local' declared in enclosing function 'test_reaching_scope'}} |
| 34 | local_static]() { // expected-error{{'local_static' cannot be captured because it does not have automatic storage duration}} |
| 35 | return 0; |
| 36 | }; |
| 37 | } |
| 38 | }; |
| 39 | }; |
| 40 | } |