1 | // RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s |
2 | |
3 | // Inherit a valid non-default ctor. |
4 | namespace NonDefaultCtorValid { |
5 | struct A { |
6 | A(const int &x) {} |
7 | }; |
8 | |
9 | struct B : A { |
10 | using A::A; |
11 | }; |
12 | |
13 | struct C { |
14 | struct B b; |
15 | C() : b(0) {} |
16 | }; |
17 | |
18 | void test() { |
19 | B b(0); |
20 | C c; |
21 | } |
22 | } |
23 | |
24 | // Inherit an invalid non-default ctor. |
25 | // The inherited ctor is invalid because it is unable to initialize s. |
26 | namespace NonDefaultCtorInvalid { |
27 | struct S { |
28 | S() = delete; |
29 | }; |
30 | struct A { |
31 | A(const int &x) {} |
32 | }; |
33 | |
34 | struct B : A { |
35 | using A::A; |
36 | S s; |
37 | }; |
38 | |
39 | struct C { |
40 | struct B b; |
41 | C() : b(0) {} // expected-error{{constructor inherited by 'B' from base class 'A' is implicitly deleted}} |
42 | // expected-note@-6{{constructor inherited by 'B' is implicitly deleted because field 's' has a deleted corresponding constructor}} |
43 | // expected-note@-15{{'S' has been explicitly marked deleted here}} |
44 | }; |
45 | } |
46 | |
47 | // Inherit a valid default ctor. |
48 | namespace DefaultCtorValid { |
49 | struct A { |
50 | A() {} |
51 | }; |
52 | |
53 | struct B : A { |
54 | using A::A; |
55 | }; |
56 | |
57 | struct C { |
58 | struct B b; |
59 | C() {} |
60 | }; |
61 | |
62 | void test() { |
63 | B b; |
64 | C c; |
65 | } |
66 | } |
67 | |
68 | // Inherit an invalid default ctor. |
69 | // The inherited ctor is invalid because it is unable to initialize s. |
70 | namespace DefaultCtorInvalid { |
71 | struct S { |
72 | S() = delete; |
73 | }; |
74 | struct A { |
75 | A() {} |
76 | }; |
77 | |
78 | struct B : A { |
79 | using A::A; |
80 | S s; |
81 | }; |
82 | |
83 | struct C { |
84 | struct B b; |
85 | C() {} // expected-error{{call to implicitly-deleted default constructor of 'struct B'}} |
86 | // expected-note@-6{{default constructor of 'B' is implicitly deleted because field 's' has a deleted default constructor}} |
87 | // expected-note@-15{{'S' has been explicitly marked deleted here}} |
88 | }; |
89 | } |
90 | |