blob: 39dc29796b07d4257cdb286959d012d3d4bbee9c [file] [log] [blame]
Douglas Gregor8e458f42009-02-09 18:46:07 +00001// RUN: clang -fsyntax-only -verify %s
Douglas Gregorad964b32009-02-17 01:05:43 +00002template<typename T, typename U = float> struct A { };
Douglas Gregor8e458f42009-02-09 18:46:07 +00003
4typedef A<int> A_int;
5
Douglas Gregorad964b32009-02-17 01:05:43 +00006typedef float FLOAT;
7
8A<int, FLOAT> *foo(A<int> *ptr, A<int> const *ptr2, A<int, double> *ptr3) {
Douglas Gregor8e458f42009-02-09 18:46:07 +00009 if (ptr)
Douglas Gregorad964b32009-02-17 01:05:43 +000010 return ptr; // okay
Douglas Gregor8e458f42009-02-09 18:46:07 +000011 else if (ptr2)
Douglas Gregorad964b32009-02-17 01:05:43 +000012 return ptr2; // expected-error{{incompatible type returning 'A<int> const *', expected 'A<int, FLOAT> *'}}
Douglas Gregor8e458f42009-02-09 18:46:07 +000013 else {
Douglas Gregorad964b32009-02-17 01:05:43 +000014 return ptr3; // expected-error{{incompatible type returning 'A<int, double> *', expected 'A<int, FLOAT> *'}}
Douglas Gregor8e458f42009-02-09 18:46:07 +000015 }
16}
Douglas Gregorad964b32009-02-17 01:05:43 +000017
18template<int I> struct B;
19
20const int value = 12;
21B<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