• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // RUN: %clang_cc1 -fsyntax-only -std=c++11 %s -verify
2 
test_conversion()3 void test_conversion() {
4   int (*fp1)(int) = [](int x) { return x + 1; };
5   void (*fp2)(int) = [](int x) { };
6 
7   const auto lambda = [](int x) { };
8   void (*fp3)(int) = lambda;
9 
10   volatile const auto lambda2 = [](int x) { }; // expected-note{{but method is not marked volatile}}
11   void (*fp4)(int) = lambda2; // expected-error{{no viable conversion}}
12 }
13 
test_no_conversion()14 void test_no_conversion() {
15   int (*fp1)(int) = [=](int x) { return x + 1; }; // expected-error{{no viable conversion}}
16   void (*fp2)(int) = [&](int x) { }; // expected-error{{no viable conversion}}
17 }
18 
test_wonky()19 void test_wonky() {
20   const auto l = [](int x) mutable -> int { return + 1; };
21   l(17); // okay: uses conversion function
22 }
23