aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.dg/cpp2a/constexpr-new13.C
blob: 7eed50c7f4cfdbd1313d8b505df92fe54a3d69de (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
// PR c++/93633
// { dg-do compile { target c++20 } }

struct A {
  constexpr A () : a (0) {}
  virtual int foo () { return 1 + a * 4; }
  int a;
};

struct B : A {
  constexpr B () : b (0) {}
  virtual int foo () { return 0 + b * 4; }	// { dg-message "declared here" "" { target { ! implicit_constexpr } } }
  int b;
};

constexpr int
foo ()
{
  A *a = new B ();
  a->a = 4;
  int r = a->foo ();	// { dg-error "call to non-.constexpr. function" "" { target { ! implicit_constexpr } } }
  delete a;
  return r;
}

constexpr auto a = foo ();