// RUN: clang-cc -fsyntax-only -verify %s template class X { public: void f(T x); // expected-error{{argument may not have 'void' type}} void g(T*); static int h(T, T); // expected-error 2{{argument may not have 'void' type}} }; int identity(int x) { return x; } void test(X *xi, int *ip, X *xf) { xi->f(17); xi->g(ip); xf->f(&identity); xf->g(identity); X::h(17, 25); X::h(identity, &identity); } void test_bad() { X xv; // expected-note{{in instantiation of template class 'class X' requested here}} } template class Overloading { public: int& f(T, T); // expected-note{{previous declaration is here}} float& f(T, U); // expected-error{{functions that differ only in their return type cannot be overloaded}} }; void test_ovl(Overloading *oil, int i, long l) { int &ir = oil->f(i, i); float &fr = oil->f(i, l); } void test_ovl_bad() { Overloading off; // expected-note{{in instantiation of template class 'class Overloading' requested here}} } template class HasDestructor { public: virtual ~HasDestructor() = 0; }; int i = sizeof(HasDestructor); // FIXME: forces instantiation, but // the code below should probably instantiate by itself. int abstract_destructor[__is_abstract(HasDestructor)? 1 : -1]; template class Constructors { public: Constructors(const T&); Constructors(const Constructors &other); }; void test_constructors() { Constructors ci1(17); Constructors ci2 = ci1; } template struct ConvertsTo { operator T(); }; void test_converts_to(ConvertsTo ci, ConvertsTo cip) { int i = ci; int *ip = cip; } // PR4660 template struct A0 { operator T*(); }; template struct A1; int *a(A0 &x0, A1 &x1) { int *y0 = x0; int *y1 = x1; // expected-error{{initializing}} } struct X0Base { int &f(); }; template struct X0 : X0Base { }; template struct X1 : X0 { int &f2() { return X0Base::f(); } }; void test_X1(X1 x1i) { int &ir = x1i.f2(); }