blob: bb9d39d82afe0bbb5e6f507f5b2711e080aa7ef7 [file] [log] [blame]
Daniel Dunbara5728872009-12-15 20:14:24 +00001// RUN: %clang_cc1 -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;
Douglas Gregor9af2f522009-12-01 16:58:18 +000039
40// PR5655
41template<typename T> struct Foo { }; // expected-note{{template is declared here}}
42
43void f(void) { Foo bar; } // expected-error{{without a template argument list}}