1 // RUN: %clang_cc1 -fms-compatibility -fsyntax-only -verify %s
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}}
12 class B : public A<T> {
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}}
21 template class B<int>; // expected-note {{requested here}}
22 template class B<char>;
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'}}
36 template void A2::f(int);
40 template<class T1> void f(T1) {
41 XX; //expected-error {{use of undeclared identifier 'XX'}}
44 template void A3<int>::f(int);
49 XX; //expected-error {{use of undeclared identifier 'XX'}}
52 template class A4<int>;
55 namespace lookup_dependent_bases_id_expr {
57 template<class T> class A {
64 class B : public A<T> {
71 template class B<int>;
77 namespace lookup_dependent_base_class_static_function {
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}}
88 class B : public A<T> {
91 static_func(); // expected-warning {{use of identifier 'static_func' found via unqualified lookup into dependent bases of class templates is a Microsoft extension}}
92 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}}
95 template class B<int>; // expected-note {{requested here}}
101 namespace lookup_dependent_base_class_default_argument {
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}}
111 class B : public A<T> {
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}}
120 b.g1(); // expected-note {{required here}}
121 b.g2(); // expected-note {{required here}}
127 namespace lookup_dependent_base_class_friend {
132 static void g(); // expected-note {{must qualify identifier to find this declaration in dependent base class}}
136 class A : public B<T> {
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}}
146 foo(a); // expected-note {{requested here}}
152 namespace lookup_dependent_base_no_typo_correction {
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; }
184 class Container : public Base<T> {
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}}
193 Container<A> text_provider;
194 Container<B> text_provider2;
195 text_provider2 = text_provider; // expected-note {{in instantiation of function template specialization}}
198 } // namespace PR12701
206 template <typename T> struct B : T {
207 int foo() { return a; }
208 int *bar() { return &a; }
209 int baz() { return T::a; }
210 int T::*qux() { return &T::a; }
211 static int T::*stuff() { return &T::a; }
212 static int stuff1() { return T::sa; }
213 static int *stuff2() { return &T::sa; }
216 template <typename T> struct C : T {
217 int foo() { return b; } // expected-error {{no member named 'b' in 'PR16014::C<PR16014::A>'}}
218 int *bar() { return &b; } // expected-error {{no member named 'b' in 'PR16014::C<PR16014::A>'}}
219 int baz() { return T::b; } // expected-error {{no member named 'b' in 'PR16014::A'}}
220 int T::*qux() { return &T::b; } // expected-error {{no member named 'b' in 'PR16014::A'}}
221 int T::*fuz() { return &U::a; } // expected-error {{use of undeclared identifier 'U'}}
224 template struct B<A>;
225 template struct C<A>; // expected-note-re 1+ {{in instantiation of member function 'PR16014::C<PR16014::A>::.*' requested here}}
227 template <typename T> struct D : T {
230 // FIXME: MSVC can find this in D's base T! Even worse, if ::sa exists,
231 // clang will use it instead.
232 return sa; // expected-error {{use of undeclared identifier 'sa'}}
236 template struct D<A>;