1 // RUN: %clang_cc1 -std=c++11 -verify %s
2 
3 template<int> struct X {};
4 
5 // A[n inheriting] constructor [...] has the same access as the corresponding
6 // constructor [in the base class].
7 struct A {
8 public:
9   A(X<0>) {}
10 protected:
11   A(X<1>) {}
12 private:
13   A(X<2>) {} // expected-note {{declared private here}}
14   friend class FA;
15 };
16 
17 struct B : A {
18   using A::A; // expected-error {{private constructor}} expected-note {{implicitly declared protected here}}
19   friend class FB;
20 };
21 
22 B b0{X<0>{}};
23 B b1{X<1>{}}; // expected-error {{calling a protected constructor}}
24 B b2{X<2>{}}; // expected-note {{first required here}}
25 
26 struct C : B {
27   C(X<0> x) : B(x) {}
28   C(X<1> x) : B(x) {}
29 };
30 
31 struct FB {
32   B b0{X<0>{}};
33   B b1{X<1>{}};
34 };
35 
36 struct FA : A {
37   using A::A; // expected-note 2{{here}}
38 };
39 FA fa0{X<0>{}};
40 FA fa1{X<1>{}}; // expected-error {{calling a protected constructor}}
41 FA fa2{X<2>{}}; // expected-error {{calling a private constructor}}
42 
43 
44 // It is deleted if the corresponding constructor [...] is deleted.
45 struct G {
46   G(int) = delete; // expected-note {{function has been explicitly marked deleted here}}
47   template<typename T> G(T*) = delete; // expected-note {{function has been explicitly marked deleted here}}
48 };
49 struct H : G {
50   using G::G; // expected-note 2{{deleted constructor was inherited here}}
51 };
52 H h1(5); // expected-error {{call to deleted constructor of 'H'}}
53 H h2("foo"); // expected-error {{call to deleted constructor of 'H'}}
54 
55 
56 // Core defect: It is also deleted if multiple base constructors generate the
57 // same signature.
58 namespace DRnnnn {
59   struct A {
60     constexpr A(int, float = 0) {}
61     explicit A(int, int = 0) {} // expected-note {{constructor cannot be inherited}}
62 
63     A(int, int, int = 0) = delete;
64   };
65   struct B : A {
66     using A::A; // expected-note {{here}}
67   };
68 
69   constexpr B b0(0, 0.0f); // ok, constexpr
70   B b1(0, 1); // expected-error {{call to deleted constructor of 'DRnnnn::B'}}
71 }
72