Douglas Gregor | 7429654 | 2009-02-27 19:31:52 +0000 | [diff] [blame] | 1 | // RUN: clang -fsyntax-only -verify %s |
Douglas Gregor | 7429654 | 2009-02-27 19:31:52 +0000 | [diff] [blame] | 2 | template<typename T, typename U = const T> struct Def1; |
| 3 | |
| 4 | template<> struct Def1<int> { |
| 5 | void foo(); |
| 6 | }; |
| 7 | |
| 8 | template<> struct Def1<const int> { // expected-note{{previous definition is here}} |
| 9 | void bar(); |
| 10 | }; |
| 11 | |
Douglas Gregor | f57dcd0 | 2009-02-28 00:25:32 +0000 | [diff] [blame^] | 12 | template<> struct Def1<int&> { |
| 13 | void wibble(); |
| 14 | }; |
| 15 | |
| 16 | void test_Def1(Def1<int, const int> *d1, Def1<const int, const int> *d2, |
| 17 | Def1<int&, int&> *d3) { |
Douglas Gregor | 7429654 | 2009-02-27 19:31:52 +0000 | [diff] [blame] | 18 | d1->foo(); |
| 19 | d2->bar(); |
Douglas Gregor | f57dcd0 | 2009-02-28 00:25:32 +0000 | [diff] [blame^] | 20 | d3->wibble(); |
Douglas Gregor | 7429654 | 2009-02-27 19:31:52 +0000 | [diff] [blame] | 21 | } |
| 22 | |
Douglas Gregor | f57dcd0 | 2009-02-28 00:25:32 +0000 | [diff] [blame^] | 23 | template<typename T, // FIXME: bad error message below, needs better location info |
| 24 | typename T2 = const T*> // expected-error{{'T2' declared as a pointer to a reference}} |
| 25 | struct Def2; |
| 26 | |
| 27 | template<> struct Def2<int> { |
| 28 | void foo(); |
| 29 | }; |
| 30 | |
| 31 | void test_Def2(Def2<int, int const*> *d2) { |
| 32 | d2->foo(); |
| 33 | } |
| 34 | |
| 35 | Def2<int&> *d2; |
| 36 | |
| 37 | |
Douglas Gregor | 7429654 | 2009-02-27 19:31:52 +0000 | [diff] [blame] | 38 | template<> struct Def1<const int, const int> { }; // expected-error{{redefinition of 'Def1'}} |
| 39 | |
Douglas Gregor | f57dcd0 | 2009-02-28 00:25:32 +0000 | [diff] [blame^] | 40 | template<typename T, typename T2 = T&> struct Def3; |
| 41 | |
| 42 | template<> struct Def3<int> { |
| 43 | void foo(); |
| 44 | }; |
| 45 | |
| 46 | template<> struct Def3<int&> { |
| 47 | void bar(); |
| 48 | }; |
| 49 | |
| 50 | void test_Def3(Def3<int, int&> *d3a, Def3<int&, int&> *d3b) { |
| 51 | d3a->foo(); |
| 52 | d3b->bar(); |
| 53 | } |
| 54 | |
| 55 | |
| 56 | template<typename T, typename T2 = T[]> struct Def4; |
| 57 | |
| 58 | template<> struct Def4<int> { |
| 59 | void foo(); |
| 60 | }; |
| 61 | |
| 62 | void test_Def4(Def4<int, int[]> *d4a) { |
| 63 | d4a->foo(); |
| 64 | } |
| 65 | |
| 66 | template<typename T, typename T2 = T const[12]> struct Def5; |
| 67 | |
| 68 | template<> struct Def5<int> { |
| 69 | void foo(); |
| 70 | }; |
| 71 | |
| 72 | template<> struct Def5<int, int const[13]> { |
| 73 | void bar(); |
| 74 | }; |
| 75 | |
| 76 | void test_Def5(Def5<int, const int[12]> *d5a, Def5<int, const int[13]> *d5b) { |
| 77 | d5a->foo(); |
| 78 | d5b->bar(); |
| 79 | } |
| 80 | |