/cp 2019-12-03 Paolo Carlini <paolo.carlini@oracle.com> * typeck.c (cp_build_addr_expr_1): Use the cp_expr_loc_or_input_loc location in a few additional diagnostics; tidy. (check_return_expr): Likewise. * typeck.c (cp_build_addr_expr_1): Use tree_strip_any_location_wrapper for the address of main pedwarn. /testsuite 2019-12-03 Paolo Carlini <paolo.carlini@oracle.com> * g++.dg/diagnostic/inconsistent-deduction-1.C: New. * g++.dg/diagnostic/returning-a-value-1.C: Likewise. * g++.dg/cpp0x/decltype3.C: Check location(s) too. * g++.dg/cpp0x/decltype4.C: Likewise. * g++.dg/cpp0x/lambda/lambda-deduce-ext-neg.C: Likewise. * g++.dg/cpp2a/consteval13.C: Likewise. * g++.dg/expr/pmf-1.C: Likewise. * g++.dg/other/ptrmem2.C: Likewise. * g++.dg/template/ptrmem17.C: Likewise. * g++.old-deja/g++.bugs/900213_03.C: Likewise. * g++.old-deja/g++.other/pmf7.C: Likewise. * g++.old-deja/g++.other/ptrmem7.C: Likewise. * g++.dg/diagnostic/main2.C: New. From-SVN: r278947
18 lines
514 B
C
18 lines
514 B
C
// { dg-do compile }
|
|
// { dg-options "-std=c++2a" }
|
|
|
|
consteval int bar () { return 42; }
|
|
consteval int baz () { return 1; }
|
|
typedef int (*fnptr) ();
|
|
consteval fnptr quux () { return bar; }
|
|
|
|
void
|
|
foo ()
|
|
{
|
|
auto qux = [] (fnptr a = quux ()) consteval { return a (); };
|
|
constexpr auto c = qux (baz); // { dg-error "28:taking address of an immediate function" }
|
|
constexpr auto d = qux (bar); // { dg-error "28:taking address of an immediate function" }
|
|
static_assert (c == 1);
|
|
static_assert (d == 42);
|
|
}
|