blob: ae6dc9c30fa12b0f4735f2d3218c2c280d3e351d [file] [log] [blame]
Daniel Dunbara5728872009-12-15 20:14:24 +00001// RUN: %clang_cc1 -fsyntax-only -verify %s
Douglas Gregord9842d02009-10-14 16:50:13 +00002
3// Make sure that copy constructors and assignment operators are properly
4// generated when there is a matching
5
6// PR5072
7template<typename T>
8struct X {
9 template<typename U>
10 X(const X<U>& other)
11 : value(other.value + 1) { } // expected-error{{binary expression}}
12
13 template<typename U>
14 X& operator=(const X<U>& other) {
15 value = other.value + 1; // expected-error{{binary expression}}
16 return *this;
17 }
18
19 T value;
20};
21
22struct Y {};
23
24X<int Y::*> test0(X<int Y::*> x) { return x; }
25X<int> test1(X<long> x) { return x; }
26
27
28X<int> test2(X<int Y::*> x) {
29 return x; // expected-note{{instantiation}}
30}
31
32void test3(X<int> &x, X<int> xi, X<long> xl, X<int Y::*> xmptr) {
33 x = xi;
34 x = xl;
35 x = xmptr; // expected-note{{instantiation}}
Douglas Gregor682054c2009-10-30 22:48:49 +000036}
37
38struct X1 {
39 X1 &operator=(const X1&);
40};
41
42template<typename T>
43struct X2 : X1 {
44 template<typename U> X2 &operator=(const U&);
45};
46
47struct X3 : X2<int> {
48};
49
50void test_X2(X3 &to, X3 from) {
51 to = from;
52}