146c59614SDouglas Gregor // RUN: %clang_cc1 -fsyntax-only -verify %s
246c59614SDouglas Gregor 
346c59614SDouglas Gregor template<typename T, typename U>
446c59614SDouglas Gregor struct X0 : T::template apply<U> {
X0X0546c59614SDouglas Gregor   X0(U u) : T::template apply<U>(u) { }
646c59614SDouglas Gregor };
718473f32SDouglas Gregor 
818473f32SDouglas Gregor template<typename T, typename U>
920c38a7cSDouglas Gregor struct X1 : T::apply<U> { }; // expected-error{{use 'template' keyword to treat 'apply' as a dependent template name}}
1018473f32SDouglas Gregor 
1118473f32SDouglas Gregor template<typename T>
12b23c5e8cSRichard Smith struct X2 : vector<T> { }; // expected-error{{no template named 'vector'}}
13d2e6a457SDouglas Gregor 
14d2e6a457SDouglas Gregor namespace PR6031 {
15d2e6a457SDouglas Gregor   template<typename T>
16d2e6a457SDouglas Gregor   struct A;
17d2e6a457SDouglas Gregor 
18d2e6a457SDouglas Gregor   template <class X>
19d2e6a457SDouglas Gregor   struct C { };
20d2e6a457SDouglas Gregor 
21d2e6a457SDouglas Gregor   template <class TT>
22d2e6a457SDouglas Gregor   struct II {
23d2e6a457SDouglas Gregor     typedef typename A<TT>::type type;
24d2e6a457SDouglas Gregor   };
25d2e6a457SDouglas Gregor 
26d2e6a457SDouglas Gregor   template <class TT>
27d2e6a457SDouglas Gregor   struct FI : II<TT>
28d2e6a457SDouglas Gregor   {
29d2e6a457SDouglas Gregor     C<typename FI::type> a;
30d2e6a457SDouglas Gregor   };
31d2e6a457SDouglas Gregor 
32d2e6a457SDouglas Gregor   template <class TT>
33d2e6a457SDouglas Gregor   struct FI2
34d2e6a457SDouglas Gregor   {
3545855df4SRichard Smith     C<typename FI2::type> a; // expected-error{{no type named 'type' in 'FI2<TT>'}}
36d2e6a457SDouglas Gregor   };
37d2e6a457SDouglas Gregor 
38d2e6a457SDouglas Gregor   template<typename T>
39d2e6a457SDouglas Gregor   struct Base {
40d2e6a457SDouglas Gregor     class Nested { };
41d2e6a457SDouglas Gregor     template<typename U> struct MemberTemplate { };
42d2e6a457SDouglas Gregor     int a;
43d2e6a457SDouglas Gregor   };
44d2e6a457SDouglas Gregor 
45d2e6a457SDouglas Gregor   template<typename T>
46d2e6a457SDouglas Gregor   struct HasDepBase : Base<T> {
fooPR6031::HasDepBase47d2e6a457SDouglas Gregor     int foo() {
48d2e6a457SDouglas Gregor       class HasDepBase::Nested nested;
49d2e6a457SDouglas Gregor       typedef typename HasDepBase::template MemberTemplate<T>::type type;
50d2e6a457SDouglas Gregor       return HasDepBase::a;
51d2e6a457SDouglas Gregor     }
52d2e6a457SDouglas Gregor   };
53d2e6a457SDouglas Gregor 
54d2e6a457SDouglas Gregor   template<typename T>
55d2e6a457SDouglas Gregor   struct NoDepBase {
fooPR6031::NoDepBase56d2e6a457SDouglas Gregor     int foo() {
57f5af3584SDouglas Gregor       class NoDepBase::Nested nested; // expected-error{{no class named 'Nested' in 'NoDepBase<T>'}}
5888c7ffafSRichard Smith       typedef typename NoDepBase::template MemberTemplate<T>::type type; // expected-error{{no member named 'MemberTemplate' in 'NoDepBase<T>'}}
5985f90559SJohn McCall       return NoDepBase::a; // expected-error{{no member named 'a' in 'NoDepBase<T>'}}
60d2e6a457SDouglas Gregor     }
61d2e6a457SDouglas Gregor   };
62d2e6a457SDouglas Gregor }
63d0d2ee0eSDouglas Gregor 
64d0d2ee0eSDouglas Gregor namespace Ambig {
65d0d2ee0eSDouglas Gregor   template<typename T>
66d0d2ee0eSDouglas Gregor   struct Base1 {
67*7c327db3SRichard Smith     typedef int type; // expected-note{{member type 'int' found by ambiguous name lookup}}
68d0d2ee0eSDouglas Gregor   };
69d0d2ee0eSDouglas Gregor 
70d0d2ee0eSDouglas Gregor   struct Base2 {
71*7c327db3SRichard Smith     typedef float type; // expected-note{{member type 'float' found by ambiguous name lookup}}
72d0d2ee0eSDouglas Gregor   };
73d0d2ee0eSDouglas Gregor 
74d0d2ee0eSDouglas Gregor   template<typename T>
75d0d2ee0eSDouglas Gregor   struct Derived : Base1<T>, Base2 {
76d0d2ee0eSDouglas Gregor     typedef typename Derived::type type; // expected-error{{member 'type' found in multiple base classes of different types}}
fooAmbig::Derived77d0d2ee0eSDouglas Gregor     type *foo(float *fp) { return fp; }
78d0d2ee0eSDouglas Gregor   };
79d0d2ee0eSDouglas Gregor 
80d0d2ee0eSDouglas Gregor   Derived<int> di; // expected-note{{instantiation of}}
81d0d2ee0eSDouglas Gregor }
829abe2377SDouglas Gregor 
839abe2377SDouglas Gregor namespace PR6081 {
849abe2377SDouglas Gregor   template<typename T>
859abe2377SDouglas Gregor   struct A { };
869abe2377SDouglas Gregor 
879abe2377SDouglas Gregor   template<typename T>
889abe2377SDouglas Gregor   class B : public A<T>
899abe2377SDouglas Gregor   {
909abe2377SDouglas Gregor   public:
919abe2377SDouglas Gregor     template< class X >
f0(const X & k)929abe2377SDouglas Gregor     void f0(const X & k)
939abe2377SDouglas Gregor     {
949abe2377SDouglas Gregor       this->template f1<int>()(k);
959abe2377SDouglas Gregor     }
969abe2377SDouglas Gregor   };
979abe2377SDouglas Gregor 
989abe2377SDouglas Gregor   template<typename T>
999abe2377SDouglas Gregor   class C
1009abe2377SDouglas Gregor   {
1019abe2377SDouglas Gregor   public:
1029abe2377SDouglas Gregor     template< class X >
f0(const X & k)1039abe2377SDouglas Gregor     void f0(const X & k)
1049abe2377SDouglas Gregor     {
10588c7ffafSRichard Smith       this->template f1<int>()(k); // expected-error{{no member named 'f1' in 'C<T>'}}
1069abe2377SDouglas Gregor     }
1079abe2377SDouglas Gregor   };
1089abe2377SDouglas Gregor }
109beab56e9SDouglas Gregor 
110beab56e9SDouglas Gregor namespace PR6413 {
111beab56e9SDouglas Gregor   template <typename T> class Base_A { };
112beab56e9SDouglas Gregor 
113beab56e9SDouglas Gregor   class Base_B { };
114beab56e9SDouglas Gregor 
115beab56e9SDouglas Gregor   template <typename T>
116beab56e9SDouglas Gregor   class Derived
117beab56e9SDouglas Gregor     : public virtual Base_A<T>
118beab56e9SDouglas Gregor     , public virtual Base_B
119beab56e9SDouglas Gregor   { };
120beab56e9SDouglas Gregor }
121c3eb8016SDouglas Gregor 
122c3eb8016SDouglas Gregor namespace PR5812 {
123c3eb8016SDouglas Gregor   template <class T> struct Base {
124c3eb8016SDouglas Gregor     Base* p;
125c3eb8016SDouglas Gregor   };
126c3eb8016SDouglas Gregor 
127c3eb8016SDouglas Gregor   template <class T> struct Derived: public Base<T> {
128c3eb8016SDouglas Gregor     typename Derived::Base* p; // meaning Derived::Base<T>
129c3eb8016SDouglas Gregor   };
130c3eb8016SDouglas Gregor 
131c3eb8016SDouglas Gregor   Derived<int> di;
132c3eb8016SDouglas Gregor }
133