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