147 lines · cpp
1// RUN: %clang_cc1 -fsyntax-only -verify %s2 3template<typename T, typename U>4struct X0 : T::template apply<U> {5 X0(U u) : T::template apply<U>(u) { }6};7 8template<typename T, typename U>9struct X1 : T::apply<U> { }; // expected-error{{use 'template' keyword to treat 'apply' as a dependent template name}}10 11template<typename T>12struct X2 : vector<T> { }; // expected-error{{no template named 'vector'}}13 14namespace 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 FI234 {35 C<typename FI2::type> a; // expected-error{{no type named 'type' in 'PR6031::FI2<TT>'}}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() {57 class NoDepBase::Nested nested; // expected-error{{no class named 'Nested' in 'PR6031::NoDepBase<T>'}}58 typedef typename NoDepBase::template MemberTemplate<T>::type type; // expected-error{{no member named 'MemberTemplate' in 'PR6031::NoDepBase<T>'}}59 return NoDepBase::a; // expected-error{{no member named 'a' in 'PR6031::NoDepBase<T>'}}60 }61 };62}63 64namespace Ambig {65 template<typename T>66 struct Base1 {67 typedef int type; // expected-note{{member type 'int' found by ambiguous name lookup}}68 };69 70 struct Base2 {71 typedef float type; // expected-note{{member type 'float' found by ambiguous name lookup}}72 };73 74 template<typename T>75 struct Derived : Base1<T>, Base2 {76 typedef typename Derived::type type; // expected-error{{member 'type' found in multiple base classes of different types}}77 type *foo(float *fp) { return fp; }78 };79 80 Derived<int> di; // expected-note{{instantiation of}}81}82 83namespace PR6081 {84 template<typename T>85 struct A { };86 87 template<typename T>88 class B : public A<T>89 {90 public:91 template< class X >92 void f0(const X & k)93 {94 this->template f1<int>()(k);95 }96 };97 98 template<typename T>99 class C100 {101 public:102 template< class X >103 void f0(const X & k)104 {105 this->template f1<int>()(k); // expected-error{{no member named 'f1' in 'PR6081::C<T>'}}106 }107 };108}109 110namespace PR6413 {111 template <typename T> class Base_A { };112 113 class Base_B { };114 115 template <typename T>116 class Derived117 : public virtual Base_A<T>118 , public virtual Base_B119 { };120}121 122namespace PR5812 {123 template <class T> struct Base {124 Base* p;125 };126 127 template <class T> struct Derived: public Base<T> {128 typename Derived::Base* p; // meaning Derived::Base<T>129 };130 131 Derived<int> di;132}133 134namespace GH13826 {135template <typename T> struct A {136 typedef int type;137 struct B;138};139 140template <typename T> struct A<T>::B : A<T> {141 B::type t;142};143 144A<int> a;145A<int>::B b;146}147