blob: cb1a7f50b719d2ae60b0233bb7c25166f5053fa2 [file] [log] [blame]
Francois Pichetef04ecf2011-11-11 00:12:11 +00001// RUN: %clang_cc1 -fms-compatibility -fsyntax-only -verify %s
Francois Pichet0f74d1e2011-09-07 00:14:57 +00002
3
4template <class T>
5class A {
6public:
7 void f(T a) { }// expected-note {{must qualify identifier to find this declaration in dependent base class}}
8 void g();// expected-note {{must qualify identifier to find this declaration in dependent base class}}
9};
10
Francois Pichet0f74d1e2011-09-07 00:14:57 +000011template <class T>
12class B : public A<T> {
13public:
14 void z(T a)
15 {
16 f(a); // expected-warning {{use of identifier 'f' found via unqualified lookup into dependent bases of class templates is a Microsoft extension}}
17 g(); // expected-warning {{use of identifier 'g' found via unqualified lookup into dependent bases of class templates is a Microsoft extension}}
18 }
19};
20
21template class B<int>; // expected-note {{requested here}}
22template class B<char>;
23
24void test()
25{
26 B<int> b;
27 b.z(3);
28}
29
Richard Smith97aea952013-04-29 08:45:27 +000030struct A2 {
31 template<class T> void f(T) {
32 XX; //expected-error {{use of undeclared identifier 'XX'}}
33 A2::XX; //expected-error {{no member named 'XX' in 'A2'}}
34 }
35};
36template void A2::f(int);
37
38template<class T0>
39struct A3 {
40 template<class T1> void f(T1) {
41 XX; //expected-error {{use of undeclared identifier 'XX'}}
42 }
43};
44template void A3<int>::f(int);
45
46template<class T0>
47struct A4 {
48 void f(char) {
49 XX; //expected-error {{use of undeclared identifier 'XX'}}
50 }
51};
52template class A4<int>;
53
54
Francois Pichetef04ecf2011-11-11 00:12:11 +000055namespace lookup_dependent_bases_id_expr {
56
57template<class T> class A {
58public:
59 int var;
60};
61
62
63template<class T>
64class B : public A<T> {
65public:
66 void f() {
67 var = 3;
68 }
69};
70
71template class B<int>;
72
73}
Francois Pichet0f74d1e2011-09-07 00:14:57 +000074
Francois Pichete614d6c2011-11-15 23:33:34 +000075
76
77namespace lookup_dependent_base_class_static_function {
78
79template <class T>
80class A {
81public:
82 static void static_func();// expected-note {{must qualify identifier to find this declaration in dependent base class}}
83 void func();// expected-note {{must qualify identifier to find this declaration in dependent base class}}
84};
85
86
87template <class T>
88class B : public A<T> {
89public:
90 static void z2(){
91 static_func(); // expected-warning {{use of identifier 'static_func' found via unqualified lookup into dependent bases of class templates is a Microsoft extension}}
Francois Pichete6226ae2011-11-17 03:44:24 +000092 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}}
Francois Pichete614d6c2011-11-15 23:33:34 +000093 }
94};
95template class B<int>; // expected-note {{requested here}}
96
97}
Francois Pichete6226ae2011-11-17 03:44:24 +000098
99
100
101namespace lookup_dependent_base_class_default_argument {
102
103template<class T>
104class A {
105public:
106 static int f1(); // expected-note {{must qualify identifier to find this declaration in dependent base class}}
107 int f2(); // expected-note {{must qualify identifier to find this declaration in dependent base class}}
108};
109
110template<class T>
111class B : public A<T> {
112public:
113 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}}
114 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}}
115};
116
117void foo()
118{
119 B<int> b;
120 b.g1(); // expected-note {{required here}}
121 b.g2(); // expected-note {{required here}}
122}
123
Francois Pichetc8ff9152011-11-25 01:10:54 +0000124}
125
126
127namespace lookup_dependent_base_class_friend {
128
129template <class T>
130class B {
131public:
132 static void g(); // expected-note {{must qualify identifier to find this declaration in dependent base class}}
133};
134
135template <class T>
136class A : public B<T> {
137public:
138 friend void foo(A<T> p){
139 g(); // expected-warning {{use of identifier 'g' found via unqualified lookup into dependent bases of class templates is a Microsoft extension}}
140 }
141};
142
143int main2()
144{
145 A<int> a;
146 foo(a); // expected-note {{requested here}}
147}
148
149}
Francois Pichet4d604d62011-12-03 15:55:29 +0000150
151
152namespace lookup_dependent_base_no_typo_correction {
153
154class C {
155public:
156 int m_hWnd;
157};
158
159template <class T>
160class A : public T {
161public:
162 void f(int hWnd) {
163 m_hWnd = 1;
164 }
165};
166
167template class A<C>;
168
169}
Nico Weber4b554f42012-06-20 20:21:42 +0000170
171namespace PR12701 {
172
173class A {};
174class B {};
175
176template <class T>
177class Base {
178 public:
179 bool base_fun(void* p) { return false; } // expected-note {{must qualify identifier to find this declaration in dependent base clas}}
180 operator T*() const { return 0; }
181};
182
183template <class T>
184class Container : public Base<T> {
185 public:
186 template <typename S>
187 bool operator=(const Container<S>& rhs) {
188 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}}
189 }
190};
191
192void f() {
193 Container<A> text_provider;
194 Container<B> text_provider2;
195 text_provider2 = text_provider; // expected-note {{in instantiation of function template specialization}}
196}
197
198} // namespace PR12701