Debian Codegraph @

gcc/testsuite/g++.dg/cpp2a/constexpr-new13.C

raw
1 // PR c++/93633
2 // { dg-do compile { target c++20 } }
3
4 struct A {
5 constexpr A () : a (0) {}
6 virtual int foo () { return 1 + a * 4; }
7 int a;
8 };
9
10 struct B : A {
11 constexpr B () : b (0) {}
12 virtual int foo () { return 0 + b * 4; } // { dg-message "declared here" "" { target { ! implicit_constexpr } } }
13 int b;
14 };
15
16 constexpr int
17 foo ()
18 {
19 A *a = new B ();
20 a->a = 4;
21 int r = a->foo (); // { dg-error "call to non-.constexpr. function" "" { target { ! implicit_constexpr } } }
22 delete a;
23 return r;
24 }
25
26 constexpr auto a = foo ();