blob: 72ce056063ea5bc7f2668a2ac9fa57b8329ea0cf (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
|
// RUN: %clang_cc1 -fms-compatibility -fsyntax-only -verify %s
template <class T>
class A {
public:
void f(T a) { }// expected-note {{must qualify identifier to find this declaration in dependent base class}}
void g();// expected-note {{must qualify identifier to find this declaration in dependent base class}}
};
template <class T>
class B : public A<T> {
public:
void z(T a)
{
f(a); // expected-warning {{use of identifier 'f' found via unqualified lookup into dependent bases of class templates is a Microsoft extension}}
g(); // expected-warning {{use of identifier 'g' found via unqualified lookup into dependent bases of class templates is a Microsoft extension}}
}
};
template class B<int>; // expected-note {{requested here}}
template class B<char>;
void test()
{
B<int> b;
b.z(3);
}
struct A2 {
template<class T> void f(T) {
XX; //expected-error {{use of undeclared identifier 'XX'}}
A2::XX; //expected-error {{no member named 'XX' in 'A2'}}
}
};
template void A2::f(int);
template<class T0>
struct A3 {
template<class T1> void f(T1) {
XX; //expected-error {{use of undeclared identifier 'XX'}}
}
};
template void A3<int>::f(int);
template<class T0>
struct A4 {
void f(char) {
XX; //expected-error {{use of undeclared identifier 'XX'}}
}
};
template class A4<int>;
namespace lookup_dependent_bases_id_expr {
template<class T> class A {
public:
int var;
};
template<class T>
class B : public A<T> {
public:
void f() {
var = 3;
}
};
template class B<int>;
}
namespace lookup_dependent_base_class_static_function {
template <class T>
class A {
public:
static void static_func();// expected-note {{must qualify identifier to find this declaration in dependent base class}}
void func();// expected-note {{must qualify identifier to find this declaration in dependent base class}}
};
template <class T>
class B : public A<T> {
public:
static void z2(){
static_func(); // expected-warning {{use of identifier 'static_func' found via unqualified lookup into dependent bases of class templates is a Microsoft extension}}
func(); // expected-warning {{use of identifier 'func' found via unqualified lookup into dependent bases of class templates is a Microsoft extension}} expected-error {{call to non-static member function without an object argument}}
}
};
template class B<int>; // expected-note {{requested here}}
}
namespace lookup_dependent_base_class_default_argument {
template<class T>
class A {
public:
static int f1(); // expected-note {{must qualify identifier to find this declaration in dependent base class}}
int f2(); // expected-note {{must qualify identifier to find this declaration in dependent base class}}
};
template<class T>
class B : public A<T> {
public:
void g1(int p = f1());// expected-warning {{use of identifier 'f1' found via unqualified lookup into dependent bases of class templates is a Microsoft extension}}
void g2(int p = f2());// expected-warning {{use of identifier 'f2' found via unqualified lookup into dependent bases of class templates is a Microsoft extension}} expected-error {{call to non-static member function without an object argument}}
};
void foo()
{
B<int> b;
b.g1(); // expected-note {{required here}}
b.g2(); // expected-note {{required here}}
}
}
namespace lookup_dependent_base_class_friend {
template <class T>
class B {
public:
static void g(); // expected-note {{must qualify identifier to find this declaration in dependent base class}}
};
template <class T>
class A : public B<T> {
public:
friend void foo(A<T> p){
g(); // expected-warning {{use of identifier 'g' found via unqualified lookup into dependent bases of class templates is a Microsoft extension}}
}
};
int main2()
{
A<int> a;
foo(a); // expected-note {{requested here}}
}
}
namespace lookup_dependent_base_no_typo_correction {
class C {
public:
int m_hWnd;
};
template <class T>
class A : public T {
public:
void f(int hWnd) {
m_hWnd = 1;
}
};
template class A<C>;
}
namespace PR12701 {
class A {};
class B {};
template <class T>
class Base {
public:
bool base_fun(void* p) { return false; } // expected-note {{must qualify identifier to find this declaration in dependent base clas}}
operator T*() const { return 0; }
};
template <class T>
class Container : public Base<T> {
public:
template <typename S>
bool operator=(const Container<S>& rhs) {
return base_fun(rhs); // expected-warning {{use of identifier 'base_fun' found via unqualified lookup into dependent bases of class templates is a Microsoft extension}}
}
};
void f() {
Container<A> text_provider;
Container<B> text_provider2;
text_provider2 = text_provider; // expected-note {{in instantiation of function template specialization}}
}
} // namespace PR12701
namespace PR16014 {
struct A {
int a;
static int sa;
};
template <typename T> struct B : T {
int foo() { return a; }
int *bar() { return &a; }
int baz() { return T::a; }
int T::*qux() { return &T::a; }
static int T::*stuff() { return &T::a; }
static int stuff1() { return T::sa; }
static int *stuff2() { return &T::sa; }
};
template <typename T> struct C : T {
int foo() { return b; } // expected-error {{no member named 'b' in 'PR16014::C<PR16014::A>'}}
int *bar() { return &b; } // expected-error {{no member named 'b' in 'PR16014::C<PR16014::A>'}}
int baz() { return T::b; } // expected-error {{no member named 'b' in 'PR16014::A'}}
int T::*qux() { return &T::b; } // expected-error {{no member named 'b' in 'PR16014::A'}}
int T::*fuz() { return &U::a; } // expected-error {{use of undeclared identifier 'U'}}
};
template struct B<A>;
template struct C<A>; // expected-note-re 1+ {{in instantiation of member function 'PR16014::C<PR16014::A>::.*' requested here}}
template <typename T> struct D : T {
struct Inner {
int foo() {
// FIXME: MSVC can find this in D's base T! Even worse, if ::sa exists,
// clang will use it instead.
return sa; // expected-error {{use of undeclared identifier 'sa'}}
}
};
};
template struct D<A>;
}
|