]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - test/CXX/special/class.inhctor/p1.cpp
Vendor import of clang release_34 branch r197841 (effectively, 3.4 RC3):
[FreeBSD/FreeBSD.git] / test / CXX / special / class.inhctor / p1.cpp
1 // RUN: %clang_cc1 -std=c++11 -verify %s
2 // Per a core issue (no number yet), an ellipsis is always dropped.
3 struct A {
4   A(...); // expected-note {{here}}
5   A(int = 0, int = 0, int = 0, int = 0, ...); // expected-note 9{{here}} expected-note 2{{constructor cannot be inherited}}
6   A(int = 0, int = 0, ...); // expected-note {{here}}
7
8   template<typename T> A(T, int = 0, ...); // expected-note 5{{here}}
9
10   template<typename T, int N> A(const T (&)[N]); // expected-note 2{{here}} expected-note {{constructor cannot be inherited}}
11   template<typename T, int N> A(const T (&)[N], int = 0); // expected-note 2{{here}}
12 };
13
14 struct B : A { // expected-note 6{{candidate}}
15   using A::A; // expected-warning 4{{inheriting constructor does not inherit ellipsis}} expected-note 16{{candidate}} expected-note 3{{deleted constructor was inherited here}}
16 };
17
18 struct C {} c;
19
20 B b0{};
21 // expected-error@-1 {{call to implicitly-deleted default constructor of 'B'}}
22 // expected-note@-8 {{default constructor of 'B' is implicitly deleted because base class 'A' has multiple default constructors}}
23
24 B b1{1};
25 // expected-error@-1 {{call to deleted constructor of 'B'}}
26
27 B b2{1,2};
28 // expected-error@-1 {{call to deleted constructor of 'B'}}
29
30 B b3{1,2,3};
31 // ok
32
33 B b4{1,2,3,4};
34 // ok
35
36 B b5{1,2,3,4,5};
37 // expected-error@-1 {{no matching constructor for initialization of 'B'}}
38
39 B b6{c};
40 // ok
41
42 B b7{c,0};
43 // ok
44
45 B b8{c,0,1};
46 // expected-error@-1 {{no matching constructor}}
47
48 B b9{"foo"};
49 // FIXME: explain why the inheriting constructor was deleted
50 // expected-error@-2 {{call to deleted constructor of 'B'}}
51
52 namespace PR15755 {
53   struct X {
54     template<typename...Ts> X(int, Ts...);
55   };
56   struct Y : X {
57     using X::X;
58   };
59   struct Z : Y {
60     using Y::Y;
61   };
62   Z z(0);
63 }