Douglas Gregor | d9b600c | 2010-01-12 17:52:59 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -fsyntax-only -verify %s |
| 2 | |
| 3 | template<typename T, typename U> |
| 4 | struct X0 : T::template apply<U> { |
| 5 | X0(U u) : T::template apply<U>(u) { } |
| 6 | }; |
Douglas Gregor | 84d0a19 | 2010-01-12 21:28:44 +0000 | [diff] [blame] | 7 | |
| 8 | template<typename T, typename U> |
Douglas Gregor | d5ab9b0 | 2010-05-21 23:43:39 +0000 | [diff] [blame] | 9 | struct X1 : T::apply<U> { }; // expected-error{{use 'template' keyword to treat 'apply' as a dependent template name}} |
Douglas Gregor | 84d0a19 | 2010-01-12 21:28:44 +0000 | [diff] [blame] | 10 | |
| 11 | template<typename T> |
| 12 | struct X2 : vector<T> { }; // expected-error{{unknown template name 'vector'}} |
Douglas Gregor | 9edad9b | 2010-01-14 17:47:39 +0000 | [diff] [blame] | 13 | |
| 14 | namespace PR6031 { |
| 15 | template<typename T> |
| 16 | struct A; |
| 17 | |
| 18 | template <class X> |
| 19 | struct C { }; |
| 20 | |
| 21 | template <class TT> |
| 22 | struct II { |
| 23 | typedef typename A<TT>::type type; |
| 24 | }; |
| 25 | |
| 26 | template <class TT> |
| 27 | struct FI : II<TT> |
| 28 | { |
| 29 | C<typename FI::type> a; |
| 30 | }; |
| 31 | |
| 32 | template <class TT> |
| 33 | struct FI2 |
| 34 | { |
Richard Smith | 83a22ec | 2012-05-09 08:23:23 +0000 | [diff] [blame] | 35 | C<typename FI2::type> a; // expected-error{{no type named 'type' in 'FI2<TT>'}} |
Douglas Gregor | 9edad9b | 2010-01-14 17:47:39 +0000 | [diff] [blame] | 36 | }; |
| 37 | |
| 38 | template<typename T> |
| 39 | struct Base { |
| 40 | class Nested { }; |
| 41 | template<typename U> struct MemberTemplate { }; |
| 42 | int a; |
| 43 | }; |
| 44 | |
| 45 | template<typename T> |
| 46 | struct HasDepBase : Base<T> { |
| 47 | int foo() { |
| 48 | class HasDepBase::Nested nested; |
| 49 | typedef typename HasDepBase::template MemberTemplate<T>::type type; |
| 50 | return HasDepBase::a; |
| 51 | } |
| 52 | }; |
| 53 | |
| 54 | template<typename T> |
| 55 | struct NoDepBase { |
| 56 | int foo() { |
Douglas Gregor | 1eabb7d | 2010-03-31 23:17:41 +0000 | [diff] [blame] | 57 | class NoDepBase::Nested nested; // expected-error{{no class named 'Nested' in 'NoDepBase<T>'}} |
Douglas Gregor | 9edad9b | 2010-01-14 17:47:39 +0000 | [diff] [blame] | 58 | typedef typename NoDepBase::template MemberTemplate<T>::type type; // expected-error{{'MemberTemplate' following the 'template' keyword does not refer to a template}} \ |
Douglas Gregor | 9edad9b | 2010-01-14 17:47:39 +0000 | [diff] [blame] | 59 | // FIXME: expected-error{{unqualified-id}} |
John McCall | 7c2342d | 2010-03-10 11:27:22 +0000 | [diff] [blame] | 60 | return NoDepBase::a; // expected-error{{no member named 'a' in 'NoDepBase<T>'}} |
Douglas Gregor | 9edad9b | 2010-01-14 17:47:39 +0000 | [diff] [blame] | 61 | } |
| 62 | }; |
| 63 | } |
Douglas Gregor | 7d3f576 | 2010-01-15 01:44:47 +0000 | [diff] [blame] | 64 | |
| 65 | namespace Ambig { |
| 66 | template<typename T> |
| 67 | struct Base1 { |
| 68 | typedef int type; // expected-note{{member found by ambiguous name lookup}} |
| 69 | }; |
| 70 | |
| 71 | struct Base2 { |
| 72 | typedef float type; // expected-note{{member found by ambiguous name lookup}} |
| 73 | }; |
| 74 | |
| 75 | template<typename T> |
| 76 | struct Derived : Base1<T>, Base2 { |
| 77 | typedef typename Derived::type type; // expected-error{{member 'type' found in multiple base classes of different types}} |
| 78 | type *foo(float *fp) { return fp; } |
| 79 | }; |
| 80 | |
| 81 | Derived<int> di; // expected-note{{instantiation of}} |
| 82 | } |
Douglas Gregor | 0707bc5 | 2010-01-19 16:01:07 +0000 | [diff] [blame] | 83 | |
| 84 | namespace PR6081 { |
| 85 | template<typename T> |
| 86 | struct A { }; |
| 87 | |
| 88 | template<typename T> |
| 89 | class B : public A<T> |
| 90 | { |
| 91 | public: |
| 92 | template< class X > |
| 93 | void f0(const X & k) |
| 94 | { |
| 95 | this->template f1<int>()(k); |
| 96 | } |
| 97 | }; |
| 98 | |
| 99 | template<typename T> |
| 100 | class C |
| 101 | { |
| 102 | public: |
| 103 | template< class X > |
| 104 | void f0(const X & k) |
| 105 | { |
| 106 | this->template f1<int>()(k); // expected-error{{'f1' following the 'template' keyword does not refer to a template}} \ |
Douglas Gregor | 200b292 | 2010-09-17 22:25:06 +0000 | [diff] [blame] | 107 | // FIXME: expected-error{{unqualified-id}} \ |
| 108 | // expected-error{{function-style cast or type construction}} \ |
| 109 | // expected-error{{expected expression}} |
Douglas Gregor | 0707bc5 | 2010-01-19 16:01:07 +0000 | [diff] [blame] | 110 | } |
| 111 | }; |
| 112 | } |
Douglas Gregor | 5fe8c04 | 2010-02-27 00:25:28 +0000 | [diff] [blame] | 113 | |
| 114 | namespace PR6413 { |
| 115 | template <typename T> class Base_A { }; |
| 116 | |
| 117 | class Base_B { }; |
| 118 | |
| 119 | template <typename T> |
| 120 | class Derived |
| 121 | : public virtual Base_A<T> |
| 122 | , public virtual Base_B |
| 123 | { }; |
| 124 | } |
Douglas Gregor | bbbd54e | 2010-03-02 01:36:28 +0000 | [diff] [blame] | 125 | |
| 126 | namespace PR5812 { |
| 127 | template <class T> struct Base { |
| 128 | Base* p; |
| 129 | }; |
| 130 | |
| 131 | template <class T> struct Derived: public Base<T> { |
| 132 | typename Derived::Base* p; // meaning Derived::Base<T> |
| 133 | }; |
| 134 | |
| 135 | Derived<int> di; |
| 136 | } |