1 // RUN: %clang_cc1 -fsyntax-only -verify %s
5 void f(T x
); // expected-error{{argument may not have 'void' type}}
8 static int h(T
, T
); // expected-error {{argument may not have 'void' type}}
11 int identity(int x
) { return x
; }
13 void test(X
<int> *xi
, int *ip
, X
<int(int)> *xf
) {
19 X
<int(int)>::h(identity
, &identity
);
23 X
<void> xv
; // expected-note{{in instantiation of template class 'X<void>' requested here}}
26 template<typename T
, typename U
>
29 int& f(T
, T
); // expected-note{{previous declaration is here}}
30 float& f(T
, U
); // expected-error{{functions that differ only in their return type cannot be overloaded}}
33 void test_ovl(Overloading
<int, long> *oil
, int i
, long l
) {
34 int &ir
= oil
->f(i
, i
);
35 float &fr
= oil
->f(i
, l
);
39 Overloading
<float, float> off
; // expected-note{{in instantiation of template class 'Overloading<float, float>' requested here}}
45 virtual ~HasDestructor() = 0;
48 int i
= sizeof(HasDestructor
<int>); // FIXME: forces instantiation, but
49 // the code below should probably instantiate by itself.
50 int abstract_destructor
[__is_abstract(HasDestructor
<int>)? 1 : -1];
56 Constructors(const T
&);
57 Constructors(const Constructors
&other
);
60 void test_constructors() {
61 Constructors
<int> ci1(17);
62 Constructors
<int> ci2
= ci1
;
71 void test_converts_to(ConvertsTo
<int> ci
, ConvertsTo
<int *> cip
) {
77 template<class T
> struct A0
{ operator T
*(); };
78 template<class T
> struct A1
;
80 int *a(A0
<int> &x0
, A1
<int> &x1
) {
82 int *y1
= x1
; // expected-error{{no viable conversion}}
88 static double &g(double);
102 void test_X1(X1
<int> x1i
) {
107 struct X2
: X0Base
, U
{
108 int &f2() { return X0Base::f(); }
114 double& d1
= X0Base::g(x
);
119 template struct X3
<double>;
121 // Don't try to instantiate this, it's invalid.
123 template <class T
> class A
{};
124 template <class T
> class B
{
125 void foo(A
<test1::Undeclared
> &a
) // expected-error {{no member named 'Undeclared' in namespace 'test1'}}
128 template class B
<int>;
136 typedef void ( X::*impl_fun_ptr
)( );
137 impl_fun_ptr pImpl
= &X::template
143 template< class Processor
>
160 typedef int state_t( );
164 template < typename U
= X1
<int> > struct X2
173 typedef X2
<> X2_type
;
178 namespace SameSignatureAfterInstantiation
{
179 template<typename T
> struct S
{
180 void f(T
*); // expected-note {{previous}}
181 void f(const T
*); // expected-error-re {{multiple overloads of 'f' instantiate to the same signature 'void (const int *){{( __attribute__\(\(thiscall\)\))?}}'}}
183 S
<const int> s
; // expected-note {{instantiation}}
187 template <typename T
> struct Foobar
{
188 template <> void bazqux(typename
T::type
) {} // expected-error 2{{cannot be used prior to '::' because it has no members}}
192 // FIXME: we should suppress the "no member" errors
193 Foobar
<void>::bazqux(); // expected-error{{no member named 'bazqux' in }} expected-note{{in instantiation of template class }}
194 Foobar
<int>::bazqux(); // expected-error{{no member named 'bazqux' in }} expected-note{{in instantiation of template class }}
195 Foobar
<int>::bazqux(3); // expected-error{{no member named 'bazqux' in }}
200 struct SpecializationOfGlobalFnInClassScope
{
202 void ::Fn(); // expected-error{{cannot have a qualified name}}
205 class AbstractClassWithGlobalFn
{
207 void ::f(); // expected-error{{cannot have a qualified name}}
208 virtual void f1() = 0;