blob: a6a62354657c60d0b11593a41193c805d0309abd [file] [log] [blame]
Douglas Gregora6897272009-03-23 23:06:20 +00001// RUN: clang -fsyntax-only -verify %s
Douglas Gregora6897272009-03-23 23:06:20 +00002template<typename T>
3class X {
4public:
5 void f(T); // expected-error{{argument may not have 'void' type}}
6 // FIXME: source location isn't very good, because we're
7 // instantiating the type. Could we do better?
8 void g(T*);
9
10 static int h(T, T); // expected-error 2{{argument may not have 'void' type}}
11};
12
13int identity(int x) { return x; }
14
15void test(X<int> *xi, int *ip, X<int(int)> *xf) {
16 xi->f(17);
17 xi->g(ip);
18 xf->f(&identity);
19 xf->g(identity);
20 X<int>::h(17, 25);
21 X<int(int)>::h(identity, &identity);
22}
23
24void test_bad() {
25 X<void> xv; // expected-note{{in instantiation of template class 'class X<void>' requested here}}
26}
27
28template<typename T, typename U>
29class Overloading {
30public:
31 int& f(T, T); // expected-note{{previous declaration is here}}
32 float& f(T, U); // expected-error{{functions that differ only in their return type cannot be overloaded}}
33};
34
35void test_ovl(Overloading<int, long> *oil, int i, long l) {
36 int &ir = oil->f(i, i);
37 float &fr = oil->f(i, l);
38}
39
40void test_ovl_bad() {
41 Overloading<float, float> off; // expected-note{{in instantiation of template class 'class Overloading<float, float>' requested here}}
42}
Douglas Gregor467b1c92009-03-24 00:15:49 +000043
44template<typename T>
45class HasDestructor {
46 virtual ~HasDestructor() = 0;
47};
48
49int i = sizeof(HasDestructor<int>); // FIXME: forces instantiation, but
50 // the code below should probably instantiate by itself.
51int abstract_destructor[__is_abstract(HasDestructor<int>)? 1 : -1];