[clang] Implement lifetime analysis for lifetime_capture_by(X) (#115921)
[llvm-project.git] / clang / test / SemaTemplate / dependent-base-classes.cpp
blob92a37efaa7e73f66ef82da9cd9b5a92b08bd5c93
1 // RUN: %clang_cc1 -fsyntax-only -verify %s
3 template<typename T, typename U>
4 struct X0 : T::template apply<U> {
5 X0(U u) : T::template apply<U>(u) { }
6 };
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}}
11 template<typename T>
12 struct X2 : vector<T> { }; // expected-error{{no template named 'vector'}}
14 namespace PR6031 {
15 template<typename T>
16 struct A;
18 template <class X>
19 struct C { };
21 template <class TT>
22 struct II {
23 typedef typename A<TT>::type type;
26 template <class TT>
27 struct FI : II<TT>
29 C<typename FI::type> a;
32 template <class TT>
33 struct FI2
35 C<typename FI2::type> a; // expected-error{{no type named 'type' in 'FI2<TT>'}}
38 template<typename T>
39 struct Base {
40 class Nested { };
41 template<typename U> struct MemberTemplate { };
42 int a;
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;
54 template<typename T>
55 struct NoDepBase {
56 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>'}}
64 namespace Ambig {
65 template<typename T>
66 struct Base1 {
67 typedef int type; // expected-note{{member type 'int' found by ambiguous name lookup}}
70 struct Base2 {
71 typedef float type; // expected-note{{member type 'float' found by ambiguous name lookup}}
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; }
80 Derived<int> di; // expected-note{{instantiation of}}
83 namespace PR6081 {
84 template<typename T>
85 struct A { };
87 template<typename T>
88 class B : public A<T>
90 public:
91 template< class X >
92 void f0(const X & k)
94 this->template f1<int>()(k);
98 template<typename T>
99 class C
101 public:
102 template< class X >
103 void f0(const X & k)
105 this->template f1<int>()(k); // expected-error{{no member named 'f1' in 'C<T>'}}
110 namespace PR6413 {
111 template <typename T> class Base_A { };
113 class Base_B { };
115 template <typename T>
116 class Derived
117 : public virtual Base_A<T>
118 , public virtual Base_B
119 { };
122 namespace PR5812 {
123 template <class T> struct Base {
124 Base* p;
127 template <class T> struct Derived: public Base<T> {
128 typename Derived::Base* p; // meaning Derived::Base<T>
131 Derived<int> di;
134 namespace GH13826 {
135 template <typename T> struct A {
136 typedef int type;
137 struct B;
140 template <typename T> struct A<T>::B : A<T> {
141 B::type t;
144 A<int> a;
145 A<int>::B b;