Daily bump.
[official-gcc.git] / gcc / testsuite / g++.dg / cpp2a / consteval20.C
blobba3613318e63a4cca47a1d9d6d8f8e17c4a50df3
1 // PR c++/102753
2 // { dg-do compile { target c++20 } }
4 struct S {
5   consteval int foo () const { return 42; }
6 };
8 constexpr S s;
10 int
11 bar ()
13   auto c = &S::foo;                     // { dg-error "taking address of an immediate function" }
14   constexpr auto d = &S::foo;           // { dg-error "constant evaluation returns address of immediate function" }
15   static auto e = &S::foo;              // { dg-error "taking address of an immediate function" }
16   return (s.*&S::foo) ();               // { dg-error "taking address of an immediate function" }
19 constexpr auto a = &S::foo;             // { dg-error "constant evaluation returns address of immediate function" }
20 auto b = &S::foo;                       // { dg-error "taking address of an immediate function" }
22 consteval int
23 baz ()
25   return (s.*&S::foo) ();
28 static_assert (baz () == 42);