// RUN: %clang_cc1 -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 {{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 '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 '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{{no viable conversion}} } struct X0Base { int &f(); int& g(int); static double &g(double); }; template struct X0 : X0Base { }; template struct X1 : X0 { int &f2() { return X0Base::f(); } }; void test_X1(X1 x1i) { int &ir = x1i.f2(); } template struct X2 : X0Base, U { int &f2() { return X0Base::f(); } }; template struct X3 { void test(T x) { double& d1 = X0Base::g(x); } }; template struct X3; // Don't try to instantiate this, it's invalid. namespace test1 { template class A {}; template class B { void foo(A &a) // expected-error {{no member named 'Undeclared' in namespace 'test1'}} {} }; template class B; } namespace PR6947 { template< class T > struct X { int f0( ) { typedef void ( X::*impl_fun_ptr )( ); impl_fun_ptr pImpl = &X::template f0_impl1; } private: int f1() { } template< class Processor> void f0_impl1( ) { } }; char g0() { X pc; pc.f0(); } } namespace PR7022 { template struct X1 { typedef int state_t( ); state_t g ; }; template < typename U = X1 > struct X2 { X2( U = U()) { } }; void m(void) { typedef X2<> X2_type; X2_type c; } }