xref: /llvm-project/clang/test/SemaTemplate/constructor-template.cpp (revision ff7028a55e8c8524dee4a86e3deda3d4a8ff2d88)
1 // RUN: clang-cc -fsyntax-only -verify %s
2 
3 struct 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 
13 void accept_X0(X0);
14 
15 void 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 
30 template<typename T>
31 struct X1 {
32   X1(const X1&);
33   template<typename U> X1(const X1<U>&);
34 };
35 
36 template<typename T>
37 struct Outer {
38   typedef X1<T> A;
39 
40   A alloc;
41 
42   explicit Outer(const A& a) : alloc(a) { }
43 };
44 
45 void test_X1(X1<int> xi) {
46   Outer<int> oi(xi);
47   Outer<float> of(xi);
48 }
49 
50 // PR4655
51 template<class C> struct A {};
52 template <> struct A<int>{A(const A<int>&);};
53 struct B { A<int> x; B(B& a) : x(a.x) {} };
54 
55