blob: 2eb2b7a88cde7fb7ad03021afbeb1024bfaca34f [file] [log] [blame]
// RUN: clang -fsyntax-only -verify %s
template<typename T>
class X {
public:
void f(T); // expected-error{{argument may not have 'void' type}}
// FIXME: source location isn't very good, because we're
// instantiating the type. Could we do better?
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<int> *xi, int *ip, X<int(int)> *xf) {
xi->f(17);
xi->g(ip);
xf->f(&identity);
xf->g(identity);
X<int>::h(17, 25);
X<int(int)>::h(identity, &identity);
}
void test_bad() {
X<void> xv; // expected-note{{in instantiation of template class 'class X<void>' requested here}}
}
template<typename T, typename U>
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<int, long> *oil, int i, long l) {
int &ir = oil->f(i, i);
float &fr = oil->f(i, l);
}
void test_ovl_bad() {
Overloading<float, float> off; // expected-note{{in instantiation of template class 'class Overloading<float, float>' requested here}}
}