c++: Improve location information in constant evaluation
[official-gcc.git] / gcc / testsuite / g++.dg / cpp1z / constexpr-lambda8.C
blob82351ff0c54bdf51c1b2cd66088dbfa44ea0ecd1
1 // Testcase from P0170R1
2 // { dg-do compile { target c++17 } }
4 auto Fwd = [](int (*fp)(int), auto a) { return fp(a); };
5 auto C = [](auto a) { return a; };
6 static_assert( Fwd(C ,3) == 3); // OK
8 // No specialization of the function call operator template can be constexpr
9 // (because of the local static).
10 auto NC = [](auto a) { static int s; return a; }; // { dg-error "static" }
11 // { dg-error "called in a constant expression" "" { target *-*-* } .-1 }
13 static_assert( Fwd(NC ,3) == 3); // { dg-error "" }
14 // { dg-message "operator int" "" { target *-*-* } .-1 }
16 // We look for the string "operator int" to check that we aren't trying to do
17 // template pretty-printing in an expression; that gets incredibly unwieldy
18 // with the decltype magic we do for lambdas.