35 lines · cpp
1// RUN: %clang_cc1 -fsyntax-only -std=c++11 %s -verify2// RUN: %clang_cc1 -fsyntax-only -std=c++1z %s -verify3// RUN: %clang_cc1 -fsyntax-only -std=c++11 %s -triple i386-windows-pc -verify4// RUN: %clang_cc1 -fsyntax-only -std=c++1z %s -triple i386-windows-pc -verify5 6void test_conversion() {7 int (*fp1)(int) = [](int x) { return x + 1; };8 void (*fp2)(int) = [](int x) { };9 10 const auto lambda = [](int x) { };11 void (*fp3)(int) = lambda;12 13 volatile const auto lambda2 = [](int x) { }; // expected-note{{but method is not marked volatile}}14 void (*fp4)(int) = lambda2; // expected-error{{no viable conversion}}15 16 void (*fp5)(int) noexcept = [](int x) { };17#if __cplusplus > 201402L18 // expected-error@-2 {{no viable}} expected-note@-2 {{candidate}}19 void (*fp5a)(int) noexcept = [](auto x) { };20 // expected-error@-1 {{no viable}} expected-note@-1 {{candidate}}21 void (*fp5b)(int) noexcept = [](auto x) noexcept { };22#endif23 void (*fp6)(int) noexcept = [](int x) noexcept { };24}25 26void test_no_conversion() { 27 int (*fp1)(int) = [=](int x) { return x + 1; }; // expected-error{{no viable conversion}}28 void (*fp2)(int) = [&](int x) { }; // expected-error{{no viable conversion}}29}30 31void test_wonky() {32 const auto l = [](int x) mutable -> int { return + 1; };33 l(17); // okay: uses conversion function34}35