153a9bdf1SDouglas Gregor // RUN: %clang_cc1 -std=c++11 %s -verify 253a9bdf1SDouglas Gregor 38c50e7c5SDouglas Gregor int GlobalVar; // expected-note {{declared here}} 453a9bdf1SDouglas Gregor 553a9bdf1SDouglas Gregor namespace N { 653a9bdf1SDouglas Gregor int AmbiguousVar; // expected-note {{candidate}} 753a9bdf1SDouglas Gregor } 853a9bdf1SDouglas Gregor int AmbiguousVar; // expected-note {{candidate}} 953a9bdf1SDouglas Gregor using namespace N; 1053a9bdf1SDouglas Gregor 1153a9bdf1SDouglas Gregor class X0 { 1253a9bdf1SDouglas Gregor int Member; 1353a9bdf1SDouglas Gregor 1453a9bdf1SDouglas Gregor static void Overload(int); 1553a9bdf1SDouglas Gregor void Overload(); 1653a9bdf1SDouglas Gregor virtual X0& Overload(float); 1753a9bdf1SDouglas Gregor explicit_capture()1853a9bdf1SDouglas Gregor void explicit_capture() { 198c50e7c5SDouglas Gregor int variable; // expected-note {{declared here}} 20656bc62aSDouglas Gregor (void)[&Overload] () {}; // expected-error {{does not name a variable}} 21656bc62aSDouglas Gregor (void)[&GlobalVar] () {}; // expected-error {{does not have automatic storage duration}} 22656bc62aSDouglas Gregor (void)[&AmbiguousVar] () {}; // expected-error {{reference to 'AmbiguousVar' is ambiguous}} 23656bc62aSDouglas Gregor (void)[&Variable] () {}; // expected-error {{use of undeclared identifier 'Variable'; did you mean 'variable'}} 2453a9bdf1SDouglas Gregor } 2553a9bdf1SDouglas Gregor }; 26*f02455e5SDouglas Gregor test_reaching_scope()27*f02455e5SDouglas Gregorvoid test_reaching_scope() { 28*f02455e5SDouglas Gregor int local; // expected-note{{declared here}} 29*f02455e5SDouglas Gregor static int local_static; // expected-note{{'local_static' declared here}} 30*f02455e5SDouglas Gregor (void)[=]() { 31*f02455e5SDouglas Gregor struct InnerLocal { 32*f02455e5SDouglas Gregor void member() { 33*f02455e5SDouglas Gregor (void)[local, // expected-error{{reference to local variable 'local' declared in enclosing function 'test_reaching_scope'}} 34*f02455e5SDouglas Gregor local_static]() { // expected-error{{'local_static' cannot be captured because it does not have automatic storage duration}} 35*f02455e5SDouglas Gregor return 0; 36*f02455e5SDouglas Gregor }; 37*f02455e5SDouglas Gregor } 38*f02455e5SDouglas Gregor }; 39*f02455e5SDouglas Gregor }; 40*f02455e5SDouglas Gregor } 41