Home | History | Annotate | Download | only in SemaTemplate
      1 // RUN: %clang_cc1 -fms-compatibility -fsyntax-only -verify %s
      2 
      3 
      4 template <class T>
      5 class A {
      6 public:
      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 
     11 
     12 template <class T>
     13 class B : public A<T> {
     14 public:
     15 	void z(T a)
     16     {
     17        f(a); // expected-warning {{use of identifier 'f' found via unqualified lookup into dependent bases of class templates is a Microsoft extension}}
     18        g(); // expected-warning {{use of identifier 'g' found via unqualified lookup into dependent bases of class templates is a Microsoft extension}}
     19     }
     20 };
     21 
     22 template class B<int>; // expected-note {{requested here}}
     23 template class B<char>;
     24 
     25 void test()
     26 {
     27     B<int> b;
     28     b.z(3);
     29 }
     30 
     31 namespace lookup_dependent_bases_id_expr {
     32 
     33 template<class T> class A {
     34 public:
     35   int var;
     36 };
     37 
     38 
     39 template<class T>
     40 class B : public A<T> {
     41 public:
     42   void f() {
     43     var = 3;
     44   }
     45 };
     46 
     47 template class B<int>;
     48 
     49 }
     50 
     51 
     52 
     53 namespace lookup_dependent_base_class_static_function {
     54 
     55 template <class T>
     56 class A {
     57 public:
     58    static void static_func();// expected-note {{must qualify identifier to find this declaration in dependent base class}}
     59    void func();// expected-note {{must qualify identifier to find this declaration in dependent base class}}
     60 };
     61 
     62 
     63 template <class T>
     64 class B : public A<T> {
     65 public:
     66   static void z2(){
     67     static_func();  // expected-warning {{use of identifier 'static_func' found via unqualified lookup into dependent bases of class templates is a Microsoft extension}}
     68     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}}
     69   }
     70 };
     71 template class B<int>; // expected-note {{requested here}}
     72 
     73 }
     74 
     75 
     76 
     77 namespace lookup_dependent_base_class_default_argument {
     78 
     79 template<class T>
     80 class A {
     81 public:
     82   static int f1(); // expected-note {{must qualify identifier to find this declaration in dependent base class}}
     83   int f2(); // expected-note {{must qualify identifier to find this declaration in dependent base class}}
     84 };
     85 
     86 template<class T>
     87 class B : public A<T> {
     88 public:
     89   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}}
     90   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}}
     91 };
     92 
     93 void foo()
     94 {
     95 	B<int> b;
     96 	b.g1(); // expected-note {{required here}}
     97 	b.g2(); // expected-note {{required here}}
     98 }
     99 
    100 }
    101 
    102 
    103 namespace lookup_dependent_base_class_friend {
    104 
    105 template <class T>
    106 class B {
    107 public:
    108   static void g();  // expected-note {{must qualify identifier to find this declaration in dependent base class}}
    109 };
    110 
    111 template <class T>
    112 class A : public B<T> {
    113 public:
    114   friend void foo(A<T> p){
    115     g(); // expected-warning {{use of identifier 'g' found via unqualified lookup into dependent bases of class templates is a Microsoft extension}}
    116   }
    117 };
    118 
    119 int main2()
    120 {
    121   A<int> a;
    122   foo(a); // expected-note {{requested here}}
    123 }
    124 
    125 }
    126 
    127 
    128 namespace lookup_dependent_base_no_typo_correction {
    129 
    130 class C {
    131 public:
    132   int m_hWnd;
    133 };
    134 
    135 template <class T>
    136 class A : public T {
    137 public:
    138   void f(int hWnd) {
    139     m_hWnd = 1;
    140   }
    141 };
    142 
    143 template class A<C>;
    144 
    145 }
    146