1 // RUN: %clang_cc1 -fsyntax-only -verify %s
2 
3 template<typename T, typename U>
4 struct X0 : T::template apply<U> {
X0X05   X0(U u) : T::template apply<U>(u) { }
6 };
7 
8 template<typename T, typename U>
9 struct X1 : T::apply<U> { }; // expected-error{{use 'template' keyword to treat 'apply' as a dependent template name}}
10 
11 template<typename T>
12 struct X2 : vector<T> { }; // expected-error{{no template named 'vector'}}
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   {
35     C<typename FI2::type> a; // expected-error{{no type named 'type' in '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> {
fooPR6031::HasDepBase47     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 {
fooPR6031::NoDepBase56     int foo() {
57       class NoDepBase::Nested nested; // expected-error{{no class named 'Nested' in 'NoDepBase<T>'}}
58       typedef typename NoDepBase::template MemberTemplate<T>::type type; // expected-error{{no member named 'MemberTemplate' in 'NoDepBase<T>'}}
59       return NoDepBase::a; // expected-error{{no member named 'a' in 'NoDepBase<T>'}}
60     }
61   };
62 }
63 
64 namespace 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}}
fooAmbig::Derived77     type *foo(float *fp) { return fp; }
78   };
79 
80   Derived<int> di; // expected-note{{instantiation of}}
81 }
82 
83 namespace 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 >
f0(const X & k)92     void f0(const X & k)
93     {
94       this->template f1<int>()(k);
95     }
96   };
97 
98   template<typename T>
99   class C
100   {
101   public:
102     template< class X >
f0(const X & k)103     void f0(const X & k)
104     {
105       this->template f1<int>()(k); // expected-error{{no member named 'f1' in 'C<T>'}}
106     }
107   };
108 }
109 
110 namespace PR6413 {
111   template <typename T> class Base_A { };
112 
113   class Base_B { };
114 
115   template <typename T>
116   class Derived
117     : public virtual Base_A<T>
118     , public virtual Base_B
119   { };
120 }
121 
122 namespace 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