view gcc/testsuite/g++.dg/cpp1z/constexpr-lambda8.C @ 111:04ced10e8804

gcc 7
author kono
date Fri, 27 Oct 2017 22:46:09 +0900
parents
children 84e7813d76e9
line wrap: on
line source

// Testcase from P0170R1
// { dg-options -std=c++17 }

auto Fwd = [](int (*fp)(int), auto a) { return fp(a); };
auto C = [](auto a) { return a; };
static_assert( Fwd(C ,3) == 3); // OK
// No specialization of the function call operator template can be constexpr
// (because of the local static).
auto NC = [](auto a) { static int s; return a; }; // { dg-error "static" }
// { dg-message "operator int" "" { target *-*-* } .+1 }
static_assert( Fwd(NC ,3) == 3); // { dg-error "" }

// We look for the string "operator int" to check that we aren't trying to do
// template pretty-printing in an expression; that gets incredibly unwieldy
// with the decltype magic we do for lambdas.