Debian Codegraph @

gcc/testsuite/g++.dg/cpp1y/pr66443-cxx14.C

raw
1 // { dg-do run { target c++14 } }
2
3 // pr c++/66443 a synthesized ctor of an abstract class that's deleted
4 // only because of virtual base construction doesn't stop a derived
5 // class using it as a base object constructor (provided it has a
6 // suitable ctor invocation of the virtual base).
7
8 static int a_made;
9
10 struct A {
11 A *m_a = this;
12 A (int) { a_made++; }
13 };
14
15 struct B : virtual A {
16 A *m_b = this;
17 virtual bool Ok () = 0; // abstract
18 };
19
20 struct C : B {
21 // C::m_c is placed where a complete B object would put A
22 int m_c = 1729;
23 public:
24 C();
25 virtual bool Ok ();
26 };
27
28 bool C::Ok ()
29 {
30 // check everyone agreed on where A is
31 return a_made == 1 && m_a == this && m_b == this && m_c == 1729;
32 }
33
34 C::C ()
35 : A (1) // Explicit call of A's ctor
36 { }
37
38 bool Ok (C &c)
39 {
40 return true;
41 }
42
43 int main ()
44 {
45 C c;
46
47 return !c.Ok ();
48 }