]> git.ipfire.org Git - thirdparty/gcc.git/blob - gcc/testsuite/g++.dg/cpp1z/inh-ctor22.C
Implement P0136R1, Rewording inheriting constructors.
[thirdparty/gcc.git] / gcc / testsuite / g++.dg / cpp1z / inh-ctor22.C
1 // Testcase from P0136
2 // { dg-do compile { target c++11 } }
3
4 struct B1 {
5 template <class... Ts>
6 B1(int, Ts...) { }
7 };
8
9 struct B2 {
10 B2(double) { }
11 };
12
13 int get();
14
15 struct D1 : B1 { // { dg-message "B1::B1" }
16 using B1::B1; // inherits B1(int, ...)
17 int x;
18 int y = get();
19 };
20
21 void test() {
22 D1 d(2, 3, 4); // OK: B1 is initialized by calling B1(2, 3, 4),
23 // then d.x is default-initialized (no initialization is performed),
24 // then d.y is initialized by calling get()
25 D1 e; // { dg-error "" } D1 has a deleted default constructor
26 }
27
28 struct D2 : B2 {
29 using B2::B2; // { dg-message "B1::B1" }
30 B1 b;
31 };
32
33 D2 f(1.0); // { dg-error "" } B1 has no default constructor