2009-05-15 07:26:13 +08:00
|
|
|
// RUN: clang-cc -fsyntax-only -verify %s
|
|
|
|
template<typename T, typename U>
|
|
|
|
struct X0 {
|
|
|
|
void f(T x, U y) {
|
|
|
|
x + y; // expected-error{{invalid operands}}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
struct X1 { };
|
|
|
|
|
|
|
|
template struct X0<int, float>;
|
|
|
|
template struct X0<int*, int>;
|
|
|
|
template struct X0<int X1::*, int>; // expected-note{{instantiation of}}
|
2009-05-15 07:40:54 +08:00
|
|
|
|
|
|
|
template<typename T>
|
|
|
|
struct X2 {
|
|
|
|
void f(T);
|
|
|
|
|
|
|
|
T g(T x, T y) {
|
2009-05-15 08:01:03 +08:00
|
|
|
/* DeclStmt */;
|
|
|
|
T *xp = &x, &yr = y; // expected-error{{pointer to a reference}}
|
2009-05-15 07:40:54 +08:00
|
|
|
/* NullStmt */;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
template struct X2<int>;
|
2009-05-15 08:01:03 +08:00
|
|
|
template struct X2<int&>; // expected-note{{instantiation of}}
|
2009-05-15 08:15:26 +08:00
|
|
|
|
|
|
|
template<typename T>
|
|
|
|
struct X3 {
|
|
|
|
void f(T) {
|
|
|
|
Label:
|
|
|
|
T x;
|
|
|
|
goto Label;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
template struct X3<int>;
|
2009-05-15 08:48:27 +08:00
|
|
|
|
|
|
|
template <typename T> struct X4 {
|
|
|
|
T f() const {
|
|
|
|
return; // expected-warning{{non-void function 'f' should return a value}}
|
|
|
|
}
|
|
|
|
|
|
|
|
T g() const {
|
|
|
|
return 1; // expected-warning{{void function 'g' should not return a value}}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
template struct X4<void>; // expected-note{{in instantiation of template class 'X4<void>' requested here}}
|
|
|
|
template struct X4<int>; // expected-note{{in instantiation of template class 'X4<int>' requested here}}
|
2009-05-16 01:59:04 +08:00
|
|
|
|
|
|
|
struct Incomplete; // expected-note{{forward declaration}}
|
|
|
|
|
|
|
|
template<typename T> struct X5 {
|
|
|
|
T f() { } // expected-error{{incomplete result type}}
|
|
|
|
};
|
|
|
|
void test_X5(X5<Incomplete> x5); // okay!
|
|
|
|
|
|
|
|
template struct X5<Incomplete>; // expected-note{{instantiation}}
|