Clang Project

clang_source_code/test/CXX/special/class.inhctor/p1.cpp
1// RUN: %clang_cc1 -std=c++11 -verify %s
2//
3// Note: [class.inhctor] was removed by P0136R1. This tests the new behavior
4// for the wording that used to be there.
5
6struct A { // expected-note 4{{candidate constructor (the implicit}}
7  A(...); // expected-note 4{{candidate constructor}} expected-note 4{{candidate inherited constructor}}
8  A(int = 0, int = 0, int = 0, int = 0, ...); // expected-note 3{{candidate constructor}} expected-note 3{{candidate inherited constructor}}
9  A(int = 0, int = 0, ...); // expected-note 3{{candidate constructor}} expected-note 3{{candidate inherited constructor}}
10
11  template<typename T> A(T, int = 0, ...); // expected-note 3{{candidate constructor}} expected-note 3{{candidate inherited constructor}}
12
13  template<typename T, int N> A(const T (&)[N]); // expected-note {{candidate constructor}} expected-note {{candidate inherited constructor}}
14  template<typename T, int N> A(const T (&)[N], int = 0); // expected-note {{candidate constructor}} expected-note {{candidate inherited constructor}}
15};
16
17struct B : A { // expected-note 4{{candidate constructor (the implicit}}
18  using A::A; // expected-note 15{{inherited here}}
19  B(void*);
20};
21
22struct C {} c;
23
24A a0{}; // expected-error {{ambiguous}}
25B b0{}; // expected-error {{ambiguous}}
26
27A a1{1}; // expected-error {{ambiguous}}
28B b1{1}; // expected-error {{ambiguous}}
29
30A a2{1,2}; // expected-error {{ambiguous}}
31B b2{1,2}; // expected-error {{ambiguous}}
32
33A a3{1,2,3}; // ok
34B b3{1,2,3}; // ok
35
36A a4{1,2,3,4}; // ok
37B b4{1,2,3,4}; // ok
38
39A a5{1,2,3,4,5}; // ok
40B b5{1,2,3,4,5}; // ok
41
42A a6{c}; // ok
43B b6{c}; // ok
44
45A a7{c,0}; // ok
46B b7{c,0}; // ok
47
48A a8{c,0,1}; // ok
49B b8{c,0,1}; // ok
50
51A a9{"foo"}; // expected-error {{ambiguous}}
52B b9{"foo"}; // expected-error {{ambiguous}}
53
54namespace PR15755 {
55  struct X {
56    template<typename...Ts> X(int, Ts...);
57  };
58  struct Y : X {
59    using X::X;
60  };
61  struct Z : Y {
62    using Y::Y;
63  };
64  Z z(0);
65}
66