1 // RUN: %clang_cc1 -fms-compatibility -fsyntax-only -verify %s
2
3
4 template <class T>
5 class A {
6 public:
f(T a)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:
z(T a)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
test()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:
f()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:
z2()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
foo()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:
foo(A<T> p)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
main2()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:
f(int hWnd)138 void f(int hWnd) {
139 m_hWnd = 1;
140 }
141 };
142
143 template class A<C>;
144
145 }
146
147 namespace PR12701 {
148
149 class A {};
150 class B {};
151
152 template <class T>
153 class Base {
154 public:
base_fun(void * p)155 bool base_fun(void* p) { return false; } // expected-note {{must qualify identifier to find this declaration in dependent base clas}}
operator T*() const156 operator T*() const { return 0; }
157 };
158
159 template <class T>
160 class Container : public Base<T> {
161 public:
162 template <typename S>
operator =(const Container<S> & rhs)163 bool operator=(const Container<S>& rhs) {
164 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}}
165 }
166 };
167
f()168 void f() {
169 Container<A> text_provider;
170 Container<B> text_provider2;
171 text_provider2 = text_provider; // expected-note {{in instantiation of function template specialization}}
172 }
173
174 } // namespace PR12701
175