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