112695101SDouglas Gregor // RUN: %clang_cc1 -fsyntax-only -std=c++11 %s -verify 23c4f8d2eSRichard Smith // RUN: %clang_cc1 -fsyntax-only -std=c++1z %s -verify 3*6976fef0SErich Keane // RUN: %clang_cc1 -fsyntax-only -std=c++11 %s -triple i386-windows-pc -verify 4*6976fef0SErich Keane // RUN: %clang_cc1 -fsyntax-only -std=c++1z %s -triple i386-windows-pc -verify 512695101SDouglas Gregor test_conversion()612695101SDouglas Gregorvoid test_conversion() { 712695101SDouglas Gregor int (*fp1)(int) = [](int x) { return x + 1; }; 812695101SDouglas Gregor void (*fp2)(int) = [](int x) { }; 912695101SDouglas Gregor 1012695101SDouglas Gregor const auto lambda = [](int x) { }; 1112695101SDouglas Gregor void (*fp3)(int) = lambda; 1212695101SDouglas Gregor 1312695101SDouglas Gregor volatile const auto lambda2 = [](int x) { }; // expected-note{{but method is not marked volatile}} 1412695101SDouglas Gregor void (*fp4)(int) = lambda2; // expected-error{{no viable conversion}} 153c4f8d2eSRichard Smith 163c4f8d2eSRichard Smith void (*fp5)(int) noexcept = [](int x) { }; 173c4f8d2eSRichard Smith #if __cplusplus > 201402L 183c4f8d2eSRichard Smith // expected-error@-2 {{no viable}} expected-note@-2 {{candidate}} 193c4f8d2eSRichard Smith void (*fp5a)(int) noexcept = [](auto x) { }; 203c4f8d2eSRichard Smith // expected-error@-1 {{no viable}} expected-note@-1 {{candidate}} 213c4f8d2eSRichard Smith void (*fp5b)(int) noexcept = [](auto x) noexcept { }; 223c4f8d2eSRichard Smith #endif 233c4f8d2eSRichard Smith void (*fp6)(int) noexcept = [](int x) noexcept { }; 2412695101SDouglas Gregor } 2512695101SDouglas Gregor test_no_conversion()2612695101SDouglas Gregorvoid test_no_conversion() { 2712695101SDouglas Gregor int (*fp1)(int) = [=](int x) { return x + 1; }; // expected-error{{no viable conversion}} 2812695101SDouglas Gregor void (*fp2)(int) = [&](int x) { }; // expected-error{{no viable conversion}} 2912695101SDouglas Gregor } 3012695101SDouglas Gregor test_wonky()3112695101SDouglas Gregorvoid test_wonky() { 3212695101SDouglas Gregor const auto l = [](int x) mutable -> int { return + 1; }; 3312695101SDouglas Gregor l(17); // okay: uses conversion function 3412695101SDouglas Gregor } 35