blob: fd79902fdc92fe792f47c10da8fd4dd1b095a826 [file] [log] [blame]
Douglas Gregor5f62c5e2009-05-14 23:26:13 +00001// RUN: clang-cc -fsyntax-only -verify %s
2
3template<typename T, typename U>
4struct X0 {
5 void f(T x, U y) {
6 x + y; // expected-error{{invalid operands}}
7 }
8};
9
10struct X1 { };
11
12template struct X0<int, float>;
13template struct X0<int*, int>;
14template struct X0<int X1::*, int>; // expected-note{{instantiation of}}
Douglas Gregorbd5c81c2009-05-14 23:40:54 +000015
16template<typename T>
17struct X2 {
18 void f(T);
19
20 T g(T x, T y) {
Douglas Gregorb06585a2009-05-15 00:01:03 +000021 /* DeclStmt */;
22 T *xp = &x, &yr = y; // expected-error{{pointer to a reference}}
Douglas Gregorbd5c81c2009-05-14 23:40:54 +000023 /* NullStmt */;
24 }
25};
26
27template struct X2<int>;
Douglas Gregorb06585a2009-05-15 00:01:03 +000028template struct X2<int&>; // expected-note{{instantiation of}}
Anders Carlsson23daf412009-05-15 00:15:26 +000029
30template<typename T>
31struct X3 {
32 void f(T) {
33 Label:
34 T x;
35 goto Label;
36 }
37};
38
39template struct X3<int>;
Anders Carlsson92358ae2009-05-15 00:48:27 +000040
41template <typename T> struct X4 {
42 T f() const {
43 return; // expected-warning{{non-void function 'f' should return a value}}
44 }
45
46 T g() const {
47 return 1; // expected-warning{{void function 'g' should not return a value}}
48 }
49};
50
51template struct X4<void>; // expected-note{{in instantiation of template class 'X4<void>' requested here}}
52template struct X4<int>; // expected-note{{in instantiation of template class 'X4<int>' requested here}}