Douglas Gregor | 8e458f4 | 2009-02-09 18:46:07 +0000 | [diff] [blame] | 1 | // RUN: clang -fsyntax-only -verify %s |
Douglas Gregor | ad964b3 | 2009-02-17 01:05:43 +0000 | [diff] [blame] | 2 | template<typename T, typename U = float> struct A { }; |
Douglas Gregor | 8e458f4 | 2009-02-09 18:46:07 +0000 | [diff] [blame] | 3 | |
| 4 | typedef A<int> A_int; |
| 5 | |
Douglas Gregor | ad964b3 | 2009-02-17 01:05:43 +0000 | [diff] [blame] | 6 | typedef float FLOAT; |
| 7 | |
| 8 | A<int, FLOAT> *foo(A<int> *ptr, A<int> const *ptr2, A<int, double> *ptr3) { |
Douglas Gregor | 8e458f4 | 2009-02-09 18:46:07 +0000 | [diff] [blame] | 9 | if (ptr) |
Douglas Gregor | ad964b3 | 2009-02-17 01:05:43 +0000 | [diff] [blame] | 10 | return ptr; // okay |
Douglas Gregor | 8e458f4 | 2009-02-09 18:46:07 +0000 | [diff] [blame] | 11 | else if (ptr2) |
Douglas Gregor | ad964b3 | 2009-02-17 01:05:43 +0000 | [diff] [blame] | 12 | return ptr2; // expected-error{{incompatible type returning 'A<int> const *', expected 'A<int, FLOAT> *'}} |
Douglas Gregor | 8e458f4 | 2009-02-09 18:46:07 +0000 | [diff] [blame] | 13 | else { |
Douglas Gregor | ad964b3 | 2009-02-17 01:05:43 +0000 | [diff] [blame] | 14 | return ptr3; // expected-error{{incompatible type returning 'A<int, double> *', expected 'A<int, FLOAT> *'}} |
Douglas Gregor | 8e458f4 | 2009-02-09 18:46:07 +0000 | [diff] [blame] | 15 | } |
| 16 | } |
Douglas Gregor | ad964b3 | 2009-02-17 01:05:43 +0000 | [diff] [blame] | 17 | |
| 18 | template<int I> struct B; |
| 19 | |
| 20 | const int value = 12; |
| 21 | B<17 + 2> *bar(B<(19)> *ptr1, B< (::value + 7) > *ptr2, B<19 - 3> *ptr3) { |
| 22 | if (ptr1) |
| 23 | return ptr1; |
| 24 | else if (ptr2) |
| 25 | return ptr2; |
| 26 | else |
| 27 | return ptr3; // expected-error{{incompatible type returning 'B<19 - 3> *', expected 'B<17 + 2> *'}} |
| 28 | } |
| 29 | |