constructor-template.cpp revision c7e406b2ec8ae95ff2f65215330b127c437472b9
1// RUN: clang-cc -fsyntax-only -verify %s
2
3struct X0 { // expected-note{{candidate}}
4  X0(int); // expected-note{{candidate}}
5  template<typename T> X0(T);
6  template<typename T, typename U> X0(T*, U*);
7
8  // PR4761
9  template<typename T> X0() : f0(T::foo) {}
10  int f0;
11};
12
13void accept_X0(X0);
14
15void test_X0(int i, float f) {
16  X0 x0a(i);
17  X0 x0b(f);
18  X0 x0c = i;
19  X0 x0d = f;
20  accept_X0(i);
21  accept_X0(&i);
22  accept_X0(f);
23  accept_X0(&f);
24  X0 x0e(&i, &f);
25  X0 x0f(&f, &i);
26
27  X0 x0g(f, &i); // expected-error{{no matching constructor}}
28}
29
30template<typename T>
31struct X1 {
32  X1(const X1&);
33  template<typename U> X1(const X1<U>&);
34};
35
36template<typename T>
37struct Outer {
38  typedef X1<T> A;
39
40  A alloc;
41
42  explicit Outer(const A& a) : alloc(a) { }
43};
44
45void test_X1(X1<int> xi) {
46  Outer<int> oi(xi);
47  Outer<float> of(xi);
48}
49
50// PR4655
51template<class C> struct A {};
52template <> struct A<int>{A(const A<int>&);};
53struct B { A<int> x; B(B& a) : x(a.x) {} };
54