Daniel Dunbar | a572887 | 2009-12-15 20:14:24 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -fsyntax-only -verify %s |
Douglas Gregor | d7b9e9f | 2009-06-22 23:57:29 +0000 | [diff] [blame] | 2 | template<typename T, typename U> |
| 3 | struct X { |
| 4 | T f(T x, U y) { return x + y; } |
| 5 | |
| 6 | unsigned g(T x, U y) { return sizeof(f(x, y)); } |
| 7 | }; |
| 8 | |
| 9 | void test(X<int, int> *xii, X<int*, int> *xpi, X<int, int*> *xip) { |
| 10 | (void)xii->f(1, 2); |
| 11 | (void)xpi->f(0, 2); |
| 12 | (void)sizeof(xip->f(2, 0)); // okay: does not instantiate |
| 13 | (void)xip->g(2, 0); // okay: does not instantiate |
| 14 | } |
| 15 | |
Douglas Gregor | 1637be7 | 2009-06-26 00:10:03 +0000 | [diff] [blame] | 16 | template<typename T, typename U> |
| 17 | T add(T t, U u) { |
| 18 | return t + u; // expected-error{{invalid operands}} |
| 19 | } |
| 20 | |
| 21 | void test_add(char *cp, int i, int *ip) { |
| 22 | char* cp2 = add(cp, i); |
| 23 | add(cp, cp); // expected-note{{instantiation of}} |
| 24 | (void)sizeof(add(ip, ip)); |
Owen Anderson | bc0a222 | 2009-07-27 21:00:51 +0000 | [diff] [blame] | 25 | } |