Francois Pichet | ef04ecf | 2011-11-11 00:12:11 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -fms-compatibility -fsyntax-only -verify %s |
Francois Pichet | 0f74d1e | 2011-09-07 00:14:57 +0000 | [diff] [blame] | 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 | |
Francois Pichet | ef04ecf | 2011-11-11 00:12:11 +0000 | [diff] [blame] | 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 | } |
Francois Pichet | 0f74d1e | 2011-09-07 00:14:57 +0000 | [diff] [blame] | 50 | |
Francois Pichet | e614d6c | 2011-11-15 23:33:34 +0000 | [diff] [blame] | 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}} |
Francois Pichet | e6226ae | 2011-11-17 03:44:24 +0000 | [diff] [blame] | 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}} |
Francois Pichet | e614d6c | 2011-11-15 23:33:34 +0000 | [diff] [blame] | 69 | } |
| 70 | }; |
| 71 | template class B<int>; // expected-note {{requested here}} |
| 72 | |
| 73 | } |
Francois Pichet | e6226ae | 2011-11-17 03:44:24 +0000 | [diff] [blame] | 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 | |
Francois Pichet | c8ff915 | 2011-11-25 01:10:54 +0000 | [diff] [blame] | 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 | } |
Francois Pichet | 4d604d6 | 2011-12-03 15:55:29 +0000 | [diff] [blame] | 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 | } |