blob: e74a6f8dcca92a57da5e1b1c97e4826026366dfd [file] [log] [blame]
Daniel Dunbard7d5f022009-03-24 02:24:46 +00001// RUN: clang-cc -fsyntax-only -verify %s
Douglas Gregor3e00bad2009-02-17 01:05:43 +00002template<typename T, typename U = float> struct A { };
Douglas Gregor55f6b142009-02-09 18:46:07 +00003
4typedef A<int> A_int;
5
Douglas Gregor3e00bad2009-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 Gregor55f6b142009-02-09 18:46:07 +00009 if (ptr)
Douglas Gregor3e00bad2009-02-17 01:05:43 +000010 return ptr; // okay
Douglas Gregor55f6b142009-02-09 18:46:07 +000011 else if (ptr2)
Douglas Gregor3e00bad2009-02-17 01:05:43 +000012 return ptr2; // expected-error{{incompatible type returning 'A<int> const *', expected 'A<int, FLOAT> *'}}
Douglas Gregor55f6b142009-02-09 18:46:07 +000013 else {
Douglas Gregor3e00bad2009-02-17 01:05:43 +000014 return ptr3; // expected-error{{incompatible type returning 'A<int, double> *', expected 'A<int, FLOAT> *'}}
Douglas Gregor55f6b142009-02-09 18:46:07 +000015 }
16}
Douglas Gregor3e00bad2009-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
Douglas Gregora35b1d52009-03-17 23:49:44 +000030typedef B<5> B5;
Douglas Gregor9135c722009-03-25 15:40:00 +000031
32
33namespace N {
34 template<typename T> struct C {};
35}
36
37N::C<int> c1;
38typedef N::C<float> c2;