Daniel Dunbar | a572887 | 2009-12-15 20:14:24 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -fsyntax-only -verify %s |
Douglas Gregor | 6946baf | 2009-09-02 13:05:45 +0000 | [diff] [blame] | 2 | template<typename T, typename U> |
| 3 | struct is_same { |
| 4 | static const bool value = false; |
| 5 | }; |
| 6 | |
| 7 | template<typename T> |
| 8 | struct is_same<T, T> { |
| 9 | static const bool value = true; |
| 10 | }; |
| 11 | |
| 12 | template<typename MetaFun, typename T1, typename T2> |
| 13 | struct metafun_apply2 { |
| 14 | typedef typename MetaFun::template apply<T1, T2> inner; |
| 15 | typedef typename inner::type type; |
| 16 | }; |
| 17 | |
| 18 | template<typename T, typename U> struct pair; |
| 19 | |
| 20 | struct make_pair { |
| 21 | template<typename T1, typename T2> |
| 22 | struct apply { |
| 23 | typedef pair<T1, T2> type; |
| 24 | }; |
| 25 | }; |
| 26 | |
| 27 | int a0[is_same<metafun_apply2<make_pair, int, float>::type, |
| 28 | pair<int, float> >::value? 1 : -1]; |
| 29 | int a1[is_same< |
Douglas Gregor | 732281d | 2010-06-14 22:07:54 +0000 | [diff] [blame^] | 30 | typename make_pair::template apply<int, float>, // expected-warning{{'template' refers to a non-dependent template name}} |
Douglas Gregor | 6946baf | 2009-09-02 13:05:45 +0000 | [diff] [blame] | 31 | make_pair::apply<int, float> |
| 32 | >::value? 1 : -1]; |
| 33 | |
| 34 | template<typename MetaFun> |
| 35 | struct swap_and_apply2 { |
| 36 | template<typename T1, typename T2> |
| 37 | struct apply { |
| 38 | typedef typename MetaFun::template apply<T2, T1> new_metafun; |
| 39 | typedef typename new_metafun::type type; |
| 40 | }; |
| 41 | }; |
| 42 | |
| 43 | int a2[is_same<swap_and_apply2<make_pair>::apply<int, float>::type, |
| 44 | pair<float, int> >::value? 1 : -1]; |
| 45 | |
Douglas Gregor | ae44067 | 2009-09-02 13:07:20 +0000 | [diff] [blame] | 46 | template<typename MetaFun> |
| 47 | struct swap_and_apply2b { |
| 48 | template<typename T1, typename T2> |
| 49 | struct apply { |
| 50 | typedef typename MetaFun::template apply<T2, T1>::type type; |
| 51 | }; |
| 52 | }; |
| 53 | |
| 54 | int a3[is_same<swap_and_apply2b<make_pair>::apply<int, float>::type, |
| 55 | pair<float, int> >::value? 1 : -1]; |
| 56 | |
Douglas Gregor | 6946baf | 2009-09-02 13:05:45 +0000 | [diff] [blame] | 57 | template<typename T> |
| 58 | struct X0 { |
| 59 | template<typename U, typename V> |
| 60 | struct Inner; |
| 61 | |
| 62 | void f0(X0<T>::Inner<T*, T&>); // expected-note{{here}} |
| 63 | void f0(typename X0<T>::Inner<T*, T&>); // expected-error{{redecl}} |
| 64 | |
| 65 | void f1(X0<T>::Inner<T*, T&>); // expected-note{{here}} |
| 66 | void f1(typename X0<T>::template Inner<T*, T&>); // expected-error{{redecl}} |
Douglas Gregor | ae44067 | 2009-09-02 13:07:20 +0000 | [diff] [blame] | 67 | |
| 68 | void f2(typename X0<T>::Inner<T*, T&>::type); // expected-note{{here}} |
| 69 | void f2(typename X0<T>::template Inner<T*, T&>::type); // expected-error{{redecl}} |
Douglas Gregor | 6946baf | 2009-09-02 13:05:45 +0000 | [diff] [blame] | 70 | }; |
Douglas Gregor | a4e8c2a | 2010-02-05 04:39:02 +0000 | [diff] [blame] | 71 | |
| 72 | namespace PR6236 { |
| 73 | template<typename T, typename U> struct S { }; |
| 74 | |
| 75 | template<typename T> struct S<T, T> { |
| 76 | template<typename U> struct K { }; |
| 77 | |
| 78 | void f() { |
| 79 | typedef typename S<T, T>::template K<T> Foo; |
| 80 | } |
| 81 | }; |
| 82 | } |
Douglas Gregor | ae62889 | 2010-02-13 06:05:33 +0000 | [diff] [blame] | 83 | |
| 84 | namespace PR6268 { |
| 85 | template <typename T> |
| 86 | struct Outer { |
| 87 | template <typename U> |
| 88 | struct Inner {}; |
| 89 | |
| 90 | template <typename U> |
| 91 | typename Outer<T>::template Inner<U> |
| 92 | foo(typename Outer<T>::template Inner<U>); |
| 93 | }; |
| 94 | |
| 95 | template <typename T> |
| 96 | template <typename U> |
| 97 | typename Outer<T>::template Inner<U> |
| 98 | Outer<T>::foo(typename Outer<T>::template Inner<U>) { |
| 99 | return Inner<U>(); |
| 100 | } |
| 101 | } |
Douglas Gregor | a50ce32 | 2010-03-07 23:26:22 +0000 | [diff] [blame] | 102 | |
| 103 | namespace PR6463 { |
| 104 | struct B { typedef int type; }; // expected-note 2{{member found by ambiguous name lookup}} |
| 105 | struct C { typedef int type; }; // expected-note 2{{member found by ambiguous name lookup}} |
| 106 | |
| 107 | template<typename T> |
| 108 | struct A : B, C { |
| 109 | type& a(); // expected-error{{found in multiple base classes}} |
| 110 | int x; |
| 111 | }; |
| 112 | |
| 113 | // FIXME: Improve source location info here. |
| 114 | template<typename T> |
| 115 | typename A<T>::type& A<T>::a() { // expected-error{{found in multiple base classes}} |
John McCall | 63b4385 | 2010-04-29 23:50:39 +0000 | [diff] [blame] | 116 | return x; |
Douglas Gregor | a50ce32 | 2010-03-07 23:26:22 +0000 | [diff] [blame] | 117 | } |
| 118 | } |