lambda-expressions.cpp revision f050d2445ed75569ccfe0740caa900403d2ce3b3
1503384f731b5abcbf870b0a5224eb920e631db0aDouglas Gregor// RUN: %clang_cc1 -std=c++0x -Wno-unused-value -fsyntax-only -verify -fblocks %s 2e81d7e9810eed0d805263791d761ec545d2cf779Eli Friedman 372899c34e3d1abfffa241ad0ce5c4bf175e5ea51Eli Friedmannamespace std { class type_info; }; 472899c34e3d1abfffa241ad0ce5c4bf175e5ea51Eli Friedman 5e81d7e9810eed0d805263791d761ec545d2cf779Eli Friedmannamespace ExplicitCapture { 6e81d7e9810eed0d805263791d761ec545d2cf779Eli Friedman class C { 772899c34e3d1abfffa241ad0ce5c4bf175e5ea51Eli Friedman int Member; 872899c34e3d1abfffa241ad0ce5c4bf175e5ea51Eli Friedman 972899c34e3d1abfffa241ad0ce5c4bf175e5ea51Eli Friedman static void Overload(int); 1072899c34e3d1abfffa241ad0ce5c4bf175e5ea51Eli Friedman void Overload(); 1172899c34e3d1abfffa241ad0ce5c4bf175e5ea51Eli Friedman virtual C& Overload(float); 12e81d7e9810eed0d805263791d761ec545d2cf779Eli Friedman 1372899c34e3d1abfffa241ad0ce5c4bf175e5ea51Eli Friedman void ImplicitThisCapture() { 14b326ca8ffbea96f9cc8a457b0f57be880304a6f5Douglas Gregor [](){(void)Member;}; // expected-error {{'this' cannot be implicitly captured in this context}} 15b326ca8ffbea96f9cc8a457b0f57be880304a6f5Douglas Gregor [&](){(void)Member;}; 16b326ca8ffbea96f9cc8a457b0f57be880304a6f5Douglas Gregor 17b326ca8ffbea96f9cc8a457b0f57be880304a6f5Douglas Gregor [this](){(void)Member;}; 18b326ca8ffbea96f9cc8a457b0f57be880304a6f5Douglas Gregor [this]{[this]{};}; 19b326ca8ffbea96f9cc8a457b0f57be880304a6f5Douglas Gregor []{[this]{};};// expected-error {{'this' cannot be implicitly captured in this context}} 20287698336ff9f9315bf814943068d6b8261e517dAaron Ballman []{Overload(3);}; 21287698336ff9f9315bf814943068d6b8261e517dAaron Ballman []{Overload();}; // expected-error {{'this' cannot be implicitly captured in this context}} 22b326ca8ffbea96f9cc8a457b0f57be880304a6f5Douglas Gregor []{(void)typeid(Overload());}; 23287698336ff9f9315bf814943068d6b8261e517dAaron Ballman []{(void)typeid(Overload(.5f));};// expected-error {{'this' cannot be implicitly captured in this context}} 2472899c34e3d1abfffa241ad0ce5c4bf175e5ea51Eli Friedman } 25e81d7e9810eed0d805263791d761ec545d2cf779Eli Friedman }; 26e81d7e9810eed0d805263791d761ec545d2cf779Eli Friedman 27e81d7e9810eed0d805263791d761ec545d2cf779Eli Friedman void f() { 28287698336ff9f9315bf814943068d6b8261e517dAaron Ballman [this] () {}; // expected-error {{'this' cannot be captured in this context}} 29e81d7e9810eed0d805263791d761ec545d2cf779Eli Friedman } 30e81d7e9810eed0d805263791d761ec545d2cf779Eli Friedman} 3184b007fae6c0cd30fa07074d34fbe2bf61fa44f9Eli Friedman 3284b007fae6c0cd30fa07074d34fbe2bf61fa44f9Eli Friedmannamespace ReturnDeduction { 3384b007fae6c0cd30fa07074d34fbe2bf61fa44f9Eli Friedman void test() { 34287698336ff9f9315bf814943068d6b8261e517dAaron Ballman [](){ return 1; }; 35287698336ff9f9315bf814943068d6b8261e517dAaron Ballman [](){ return 1; }; 36287698336ff9f9315bf814943068d6b8261e517dAaron Ballman [](){ return ({return 1; 1;}); }; 37287698336ff9f9315bf814943068d6b8261e517dAaron Ballman [](){ return ({return 'c'; 1;}); }; // expected-error {{must match previous return type}} 38287698336ff9f9315bf814943068d6b8261e517dAaron Ballman []()->int{ return 'c'; return 1; }; 39b326ca8ffbea96f9cc8a457b0f57be880304a6f5Douglas Gregor [](){ return 'c'; return 1; }; // expected-error {{must match previous return type}} 40287698336ff9f9315bf814943068d6b8261e517dAaron Ballman []() { return; return (void)0; }; 41287698336ff9f9315bf814943068d6b8261e517dAaron Ballman [](){ return 1; return 1; }; 4284b007fae6c0cd30fa07074d34fbe2bf61fa44f9Eli Friedman } 4384b007fae6c0cd30fa07074d34fbe2bf61fa44f9Eli Friedman} 44b942cb24a060435b18fef5b43eb33d77afc0d03aEli Friedman 45b942cb24a060435b18fef5b43eb33d77afc0d03aEli Friedmannamespace ImplicitCapture { 46b942cb24a060435b18fef5b43eb33d77afc0d03aEli Friedman void test() { 47cefc7b20fdb97b989163199e0849b4325e9b7804Eli Friedman int a = 0; // expected-note 5 {{declared}} 48287698336ff9f9315bf814943068d6b8261e517dAaron Ballman []() { return a; }; // expected-error {{variable 'a' cannot be implicitly captured in a lambda with no capture-default specified}} expected-note {{begins here}} 49287698336ff9f9315bf814943068d6b8261e517dAaron Ballman [&]() { return a; }; 50287698336ff9f9315bf814943068d6b8261e517dAaron Ballman [=]() { return a; }; 51287698336ff9f9315bf814943068d6b8261e517dAaron Ballman [=]() { int* b = &a; }; // expected-error {{cannot initialize a variable of type 'int *' with an rvalue of type 'const int *'}} 52b326ca8ffbea96f9cc8a457b0f57be880304a6f5Douglas Gregor [=]() { return [&]() { return a; }; }; 53287698336ff9f9315bf814943068d6b8261e517dAaron Ballman []() { return [&]() { return a; }; }; // expected-error {{variable 'a' cannot be implicitly captured in a lambda with no capture-default specified}} expected-note {{lambda expression begins here}} 54287698336ff9f9315bf814943068d6b8261e517dAaron Ballman []() { return ^{ return a; }; };// expected-error {{variable 'a' cannot be implicitly captured in a lambda with no capture-default specified}} expected-note {{lambda expression begins here}} 55287698336ff9f9315bf814943068d6b8261e517dAaron Ballman []() { return [&a] { return a; }; }; // expected-error 2 {{variable 'a' cannot be implicitly captured in a lambda with no capture-default specified}} expected-note 2 {{lambda expression begins here}} 56287698336ff9f9315bf814943068d6b8261e517dAaron Ballman [=]() { return [&a] { return a; }; }; // 57b942cb24a060435b18fef5b43eb33d77afc0d03aEli Friedman 58b942cb24a060435b18fef5b43eb33d77afc0d03aEli Friedman const int b = 2; 59287698336ff9f9315bf814943068d6b8261e517dAaron Ballman []() { return b; }; 60b942cb24a060435b18fef5b43eb33d77afc0d03aEli Friedman 61b942cb24a060435b18fef5b43eb33d77afc0d03aEli Friedman union { // expected-note {{declared}} 62b942cb24a060435b18fef5b43eb33d77afc0d03aEli Friedman int c; 63b942cb24a060435b18fef5b43eb33d77afc0d03aEli Friedman float d; 64b942cb24a060435b18fef5b43eb33d77afc0d03aEli Friedman }; 65b942cb24a060435b18fef5b43eb33d77afc0d03aEli Friedman d = 3; 66287698336ff9f9315bf814943068d6b8261e517dAaron Ballman [=]() { return c; }; // expected-error {{unnamed variable cannot be implicitly captured in a lambda expression}} 67b942cb24a060435b18fef5b43eb33d77afc0d03aEli Friedman 68cefc7b20fdb97b989163199e0849b4325e9b7804Eli Friedman __block int e; // expected-note 3 {{declared}} 69287698336ff9f9315bf814943068d6b8261e517dAaron Ballman [&]() { return e; }; // expected-error {{__block variable 'e' cannot be captured in a lambda expression}} 70287698336ff9f9315bf814943068d6b8261e517dAaron Ballman [&e]() { return e; }; // expected-error 2 {{__block variable 'e' cannot be captured in a lambda expression}} 71b942cb24a060435b18fef5b43eb33d77afc0d03aEli Friedman 72b942cb24a060435b18fef5b43eb33d77afc0d03aEli Friedman int f[10]; // expected-note {{declared}} 73287698336ff9f9315bf814943068d6b8261e517dAaron Ballman [&]() { return f[2]; }; 74f8af98286022f72157d84951b48fde5fb369ab29Douglas Gregor (void) ^{ return []() { return f[2]; }; }; // expected-error {{variable 'f' cannot be implicitly captured in a lambda with no capture-default specified}} \ 75f8af98286022f72157d84951b48fde5fb369ab29Douglas Gregor // expected-note{{lambda expression begins here}} 76b942cb24a060435b18fef5b43eb33d77afc0d03aEli Friedman 77b942cb24a060435b18fef5b43eb33d77afc0d03aEli Friedman struct G { G(); G(G&); int a; }; // expected-note 6 {{not viable}} 78b942cb24a060435b18fef5b43eb33d77afc0d03aEli Friedman G g; 79287698336ff9f9315bf814943068d6b8261e517dAaron Ballman [=]() { const G* gg = &g; return gg->a; }; 809dd686d2be3c3785a089ff12a3d3eb64e9b32dc0Eli Friedman [=]() { return [=]{ const G* gg = &g; return gg->a; }(); }; // expected-error {{no matching constructor for initialization of 'G'}} 819dd686d2be3c3785a089ff12a3d3eb64e9b32dc0Eli Friedman (void)^{ return [=]{ const G* gg = &g; return gg->a; }(); }; // expected-error 2 {{no matching constructor for initialization of 'const G'}} 82210386eb619ea9feef425636150bdffc0538574dEli Friedman 83210386eb619ea9feef425636150bdffc0538574dEli Friedman const int h = a; // expected-note {{declared}} 84287698336ff9f9315bf814943068d6b8261e517dAaron Ballman []() { return h; }; // expected-error {{variable 'h' cannot be implicitly captured in a lambda with no capture-default specified}} expected-note {{lambda expression begins here}} 8516581335fc32abcbc6ab14eda7af38cf759664b7Richard Smith 865016a70c183a50845a0421802d161093dd0643f6Richard Smith // References can appear in constant expressions if they are initialized by 875016a70c183a50845a0421802d161093dd0643f6Richard Smith // reference constant expressions. 885016a70c183a50845a0421802d161093dd0643f6Richard Smith int i; 895016a70c183a50845a0421802d161093dd0643f6Richard Smith int &ref_i = i; // expected-note {{declared}} 9016581335fc32abcbc6ab14eda7af38cf759664b7Richard Smith [] { return ref_i; }; // expected-error {{variable 'ref_i' cannot be implicitly captured in a lambda with no capture-default specified}} expected-note {{lambda expression begins here}} 915016a70c183a50845a0421802d161093dd0643f6Richard Smith 925016a70c183a50845a0421802d161093dd0643f6Richard Smith static int j; 935016a70c183a50845a0421802d161093dd0643f6Richard Smith int &ref_j = j; 945016a70c183a50845a0421802d161093dd0643f6Richard Smith [] { return ref_j; }; // ok 95b942cb24a060435b18fef5b43eb33d77afc0d03aEli Friedman } 96b942cb24a060435b18fef5b43eb33d77afc0d03aEli Friedman} 97b09ab8c293833c3dbcbf78f0db5e01fec46966bfDouglas Gregor 98b09ab8c293833c3dbcbf78f0db5e01fec46966bfDouglas Gregornamespace PR12031 { 99b09ab8c293833c3dbcbf78f0db5e01fec46966bfDouglas Gregor struct X { 100b09ab8c293833c3dbcbf78f0db5e01fec46966bfDouglas Gregor template<typename T> 101b09ab8c293833c3dbcbf78f0db5e01fec46966bfDouglas Gregor X(const T&); 102b09ab8c293833c3dbcbf78f0db5e01fec46966bfDouglas Gregor ~X(); 103b09ab8c293833c3dbcbf78f0db5e01fec46966bfDouglas Gregor }; 104b09ab8c293833c3dbcbf78f0db5e01fec46966bfDouglas Gregor 105b09ab8c293833c3dbcbf78f0db5e01fec46966bfDouglas Gregor void f(int i, X x); 106b09ab8c293833c3dbcbf78f0db5e01fec46966bfDouglas Gregor void g() { 107b09ab8c293833c3dbcbf78f0db5e01fec46966bfDouglas Gregor const int v = 10; 108b09ab8c293833c3dbcbf78f0db5e01fec46966bfDouglas Gregor f(v, [](){}); 109b09ab8c293833c3dbcbf78f0db5e01fec46966bfDouglas Gregor } 110b09ab8c293833c3dbcbf78f0db5e01fec46966bfDouglas Gregor} 111359c89df5479810c9d4784fc0b6ab592eb136777Richard Smith 112f050d2445ed75569ccfe0740caa900403d2ce3b3Richard Smithnamespace Array { 113359c89df5479810c9d4784fc0b6ab592eb136777Richard Smith int &f(int *p); 114359c89df5479810c9d4784fc0b6ab592eb136777Richard Smith char &f(...); 115359c89df5479810c9d4784fc0b6ab592eb136777Richard Smith void g() { 116f050d2445ed75569ccfe0740caa900403d2ce3b3Richard Smith int n = -1; 117359c89df5479810c9d4784fc0b6ab592eb136777Richard Smith [=] { 118f050d2445ed75569ccfe0740caa900403d2ce3b3Richard Smith int arr[n]; // VLA 119359c89df5479810c9d4784fc0b6ab592eb136777Richard Smith } (); 120359c89df5479810c9d4784fc0b6ab592eb136777Richard Smith 121f050d2445ed75569ccfe0740caa900403d2ce3b3Richard Smith const int m = -1; 122f050d2445ed75569ccfe0740caa900403d2ce3b3Richard Smith [] { 123f050d2445ed75569ccfe0740caa900403d2ce3b3Richard Smith int arr[m]; // expected-error{{negative size}} 124359c89df5479810c9d4784fc0b6ab592eb136777Richard Smith } (); 125359c89df5479810c9d4784fc0b6ab592eb136777Richard Smith 126f050d2445ed75569ccfe0740caa900403d2ce3b3Richard Smith [&] { 127f050d2445ed75569ccfe0740caa900403d2ce3b3Richard Smith int arr[m]; // expected-error{{negative size}} 128f050d2445ed75569ccfe0740caa900403d2ce3b3Richard Smith } (); 129f050d2445ed75569ccfe0740caa900403d2ce3b3Richard Smith 130f050d2445ed75569ccfe0740caa900403d2ce3b3Richard Smith [=] { 131f050d2445ed75569ccfe0740caa900403d2ce3b3Richard Smith int arr[m]; // expected-error{{negative size}} 132359c89df5479810c9d4784fc0b6ab592eb136777Richard Smith } (); 133359c89df5479810c9d4784fc0b6ab592eb136777Richard Smith 134359c89df5479810c9d4784fc0b6ab592eb136777Richard Smith [m] { 135f050d2445ed75569ccfe0740caa900403d2ce3b3Richard Smith int arr[m]; // expected-error{{negative size}} 136359c89df5479810c9d4784fc0b6ab592eb136777Richard Smith } (); 137359c89df5479810c9d4784fc0b6ab592eb136777Richard Smith } 138359c89df5479810c9d4784fc0b6ab592eb136777Richard Smith} 13971930e02730f3afecd6e71e4d6831b4a07436a7fEli Friedman 14071930e02730f3afecd6e71e4d6831b4a07436a7fEli Friedmanvoid PR12248() 14171930e02730f3afecd6e71e4d6831b4a07436a7fEli Friedman{ 14271930e02730f3afecd6e71e4d6831b4a07436a7fEli Friedman unsigned int result = 0; 14371930e02730f3afecd6e71e4d6831b4a07436a7fEli Friedman auto l = [&]() { ++result; }; 14471930e02730f3afecd6e71e4d6831b4a07436a7fEli Friedman} 14578dae24600a877f52dbb6e58bfd5778754a00974John McCall 14678dae24600a877f52dbb6e58bfd5778754a00974John McCallnamespace ModifyingCapture { 14778dae24600a877f52dbb6e58bfd5778754a00974John McCall void test() { 14878dae24600a877f52dbb6e58bfd5778754a00974John McCall int n = 0; 14978dae24600a877f52dbb6e58bfd5778754a00974John McCall [=] { 15023dde82d9043d404ee506880796b761bfec93d0dJohn McCall n = 1; // expected-error {{cannot assign to a variable captured by copy in a non-mutable lambda}} 15178dae24600a877f52dbb6e58bfd5778754a00974John McCall }; 15278dae24600a877f52dbb6e58bfd5778754a00974John McCall } 15378dae24600a877f52dbb6e58bfd5778754a00974John McCall} 154612409ece080e814f79e06772c690d603f45fbd6Richard Smith 155612409ece080e814f79e06772c690d603f45fbd6Richard Smithnamespace VariadicPackExpansion { 156612409ece080e814f79e06772c690d603f45fbd6Richard Smith template<typename T, typename U> using Fst = T; 157612409ece080e814f79e06772c690d603f45fbd6Richard Smith template<typename...Ts> bool g(Fst<bool, Ts> ...bools); 158612409ece080e814f79e06772c690d603f45fbd6Richard Smith template<typename...Ts> bool f(Ts &&...ts) { 159612409ece080e814f79e06772c690d603f45fbd6Richard Smith return g<Ts...>([&ts] { 160612409ece080e814f79e06772c690d603f45fbd6Richard Smith if (!ts) 161612409ece080e814f79e06772c690d603f45fbd6Richard Smith return false; 162612409ece080e814f79e06772c690d603f45fbd6Richard Smith --ts; 163612409ece080e814f79e06772c690d603f45fbd6Richard Smith return true; 164612409ece080e814f79e06772c690d603f45fbd6Richard Smith } () ...); 165612409ece080e814f79e06772c690d603f45fbd6Richard Smith } 166612409ece080e814f79e06772c690d603f45fbd6Richard Smith void h() { 167612409ece080e814f79e06772c690d603f45fbd6Richard Smith int a = 5, b = 2, c = 3; 168612409ece080e814f79e06772c690d603f45fbd6Richard Smith while (f(a, b, c)) { 169612409ece080e814f79e06772c690d603f45fbd6Richard Smith } 170612409ece080e814f79e06772c690d603f45fbd6Richard Smith } 171612409ece080e814f79e06772c690d603f45fbd6Richard Smith 172612409ece080e814f79e06772c690d603f45fbd6Richard Smith struct sink { 173612409ece080e814f79e06772c690d603f45fbd6Richard Smith template<typename...Ts> sink(Ts &&...) {} 174612409ece080e814f79e06772c690d603f45fbd6Richard Smith }; 175612409ece080e814f79e06772c690d603f45fbd6Richard Smith 176612409ece080e814f79e06772c690d603f45fbd6Richard Smith template<typename...Ts> void local_class() { 177612409ece080e814f79e06772c690d603f45fbd6Richard Smith sink { 178612409ece080e814f79e06772c690d603f45fbd6Richard Smith [] (Ts t) { 179612409ece080e814f79e06772c690d603f45fbd6Richard Smith struct S : Ts { 180612409ece080e814f79e06772c690d603f45fbd6Richard Smith void f(Ts t) { 181612409ece080e814f79e06772c690d603f45fbd6Richard Smith Ts &that = *this; 182612409ece080e814f79e06772c690d603f45fbd6Richard Smith that = t; 183612409ece080e814f79e06772c690d603f45fbd6Richard Smith } 184612409ece080e814f79e06772c690d603f45fbd6Richard Smith Ts g() { return *this; }; 185612409ece080e814f79e06772c690d603f45fbd6Richard Smith }; 186612409ece080e814f79e06772c690d603f45fbd6Richard Smith S s; 187612409ece080e814f79e06772c690d603f45fbd6Richard Smith s.f(t); 188612409ece080e814f79e06772c690d603f45fbd6Richard Smith return s; 189612409ece080e814f79e06772c690d603f45fbd6Richard Smith } (Ts()).g() ... 190612409ece080e814f79e06772c690d603f45fbd6Richard Smith }; 191612409ece080e814f79e06772c690d603f45fbd6Richard Smith }; 192612409ece080e814f79e06772c690d603f45fbd6Richard Smith struct X {}; struct Y {}; 193612409ece080e814f79e06772c690d603f45fbd6Richard Smith template void local_class<X, Y>(); 194612409ece080e814f79e06772c690d603f45fbd6Richard Smith 195612409ece080e814f79e06772c690d603f45fbd6Richard Smith template<typename...Ts> void nested(Ts ...ts) { 196612409ece080e814f79e06772c690d603f45fbd6Richard Smith f( 197612409ece080e814f79e06772c690d603f45fbd6Richard Smith // Each expansion of this lambda implicitly captures all of 'ts', because 198612409ece080e814f79e06772c690d603f45fbd6Richard Smith // the inner lambda also expands 'ts'. 199612409ece080e814f79e06772c690d603f45fbd6Richard Smith [&] { 200612409ece080e814f79e06772c690d603f45fbd6Richard Smith return ts + [&] { return f(ts...); } (); 201612409ece080e814f79e06772c690d603f45fbd6Richard Smith } () ... 202612409ece080e814f79e06772c690d603f45fbd6Richard Smith ); 203612409ece080e814f79e06772c690d603f45fbd6Richard Smith } 204612409ece080e814f79e06772c690d603f45fbd6Richard Smith template void nested(int, int, int); 205612409ece080e814f79e06772c690d603f45fbd6Richard Smith 206612409ece080e814f79e06772c690d603f45fbd6Richard Smith template<typename...Ts> void nested2(Ts ...ts) { // expected-note 2{{here}} 207612409ece080e814f79e06772c690d603f45fbd6Richard Smith // Capture all 'ts', use only one. 208612409ece080e814f79e06772c690d603f45fbd6Richard Smith f([&ts...] { return ts; } ()...); 209612409ece080e814f79e06772c690d603f45fbd6Richard Smith // Capture each 'ts', use it. 210612409ece080e814f79e06772c690d603f45fbd6Richard Smith f([&ts] { return ts; } ()...); 211612409ece080e814f79e06772c690d603f45fbd6Richard Smith // Capture all 'ts', use all of them. 212612409ece080e814f79e06772c690d603f45fbd6Richard Smith f([&ts...] { return (int)f(ts...); } ()); 213612409ece080e814f79e06772c690d603f45fbd6Richard Smith // Capture each 'ts', use all of them. Ill-formed. In more detail: 214612409ece080e814f79e06772c690d603f45fbd6Richard Smith // 215612409ece080e814f79e06772c690d603f45fbd6Richard Smith // We instantiate two lambdas here; the first captures ts$0, the second 216612409ece080e814f79e06772c690d603f45fbd6Richard Smith // captures ts$1. Both of them reference both ts parameters, so both are 217612409ece080e814f79e06772c690d603f45fbd6Richard Smith // ill-formed because ts can't be implicitly captured. 218612409ece080e814f79e06772c690d603f45fbd6Richard Smith // 219612409ece080e814f79e06772c690d603f45fbd6Richard Smith // FIXME: This diagnostic does not explain what's happening. We should 220612409ece080e814f79e06772c690d603f45fbd6Richard Smith // specify which 'ts' we're referring to in its diagnostic name. We should 221612409ece080e814f79e06772c690d603f45fbd6Richard Smith // also say which slice of the pack expansion is being performed in the 222612409ece080e814f79e06772c690d603f45fbd6Richard Smith // instantiation backtrace. 223612409ece080e814f79e06772c690d603f45fbd6Richard Smith f([&ts] { return (int)f(ts...); } ()...); // \ 224612409ece080e814f79e06772c690d603f45fbd6Richard Smith // expected-error 2{{'ts' cannot be implicitly captured}} \ 225612409ece080e814f79e06772c690d603f45fbd6Richard Smith // expected-note 2{{lambda expression begins here}} 226612409ece080e814f79e06772c690d603f45fbd6Richard Smith } 227612409ece080e814f79e06772c690d603f45fbd6Richard Smith template void nested2(int); // ok 228612409ece080e814f79e06772c690d603f45fbd6Richard Smith template void nested2(int, int); // expected-note {{in instantiation of}} 229612409ece080e814f79e06772c690d603f45fbd6Richard Smith} 2309cd5b24315aea4bc58bac03cfb4874e076b013b8Eli Friedman 2319cd5b24315aea4bc58bac03cfb4874e076b013b8Eli Friedmannamespace PR13860 { 2329cd5b24315aea4bc58bac03cfb4874e076b013b8Eli Friedman void foo() { 2339cd5b24315aea4bc58bac03cfb4874e076b013b8Eli Friedman auto x = PR13860UndeclaredIdentifier(); // expected-error {{use of undeclared identifier 'PR13860UndeclaredIdentifier'}} 2349cd5b24315aea4bc58bac03cfb4874e076b013b8Eli Friedman auto y = [x]() { }; 2359cd5b24315aea4bc58bac03cfb4874e076b013b8Eli Friedman static_assert(sizeof(y), ""); 2369cd5b24315aea4bc58bac03cfb4874e076b013b8Eli Friedman } 2379cd5b24315aea4bc58bac03cfb4874e076b013b8Eli Friedman} 2387c3c6bca2662704fbe038137d8ef2e4112359586Eli Friedman 2397c3c6bca2662704fbe038137d8ef2e4112359586Eli Friedmannamespace PR13854 { 2407c3c6bca2662704fbe038137d8ef2e4112359586Eli Friedman auto l = [](void){}; 2417c3c6bca2662704fbe038137d8ef2e4112359586Eli Friedman} 24242427409fd75a48381071e6da008a3c06897437aBenjamin Kramer 24342427409fd75a48381071e6da008a3c06897437aBenjamin Kramernamespace PR14518 { 24442427409fd75a48381071e6da008a3c06897437aBenjamin Kramer auto f = [](void) { return __func__; }; // no-warning 24542427409fd75a48381071e6da008a3c06897437aBenjamin Kramer} 246