blob: 2c422dc7e3f7e905feb3509a80b27a88643cec58 [file] [log] [blame]
Francois Pichetef04ecf2011-11-11 00:12:11 +00001// RUN: %clang_cc1 -fms-compatibility -fsyntax-only -verify %s
Francois Pichet0f74d1e2011-09-07 00:14:57 +00002
3
4template <class T>
5class A {
6public:
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
12template <class T>
13class B : public A<T> {
14public:
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
22template class B<int>; // expected-note {{requested here}}
23template class B<char>;
24
25void test()
26{
27 B<int> b;
28 b.z(3);
29}
30
Francois Pichetef04ecf2011-11-11 00:12:11 +000031namespace lookup_dependent_bases_id_expr {
32
33template<class T> class A {
34public:
35 int var;
36};
37
38
39template<class T>
40class B : public A<T> {
41public:
42 void f() {
43 var = 3;
44 }
45};
46
47template class B<int>;
48
49}
Francois Pichet0f74d1e2011-09-07 00:14:57 +000050
Francois Pichete614d6c2011-11-15 23:33:34 +000051
52
53namespace lookup_dependent_base_class_static_function {
54
55template <class T>
56class A {
57public:
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
63template <class T>
64class B : public A<T> {
65public:
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 Pichete6226ae2011-11-17 03:44:24 +000068 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 Pichete614d6c2011-11-15 23:33:34 +000069 }
70};
71template class B<int>; // expected-note {{requested here}}
72
73}
Francois Pichete6226ae2011-11-17 03:44:24 +000074
75
76
77namespace lookup_dependent_base_class_default_argument {
78
79template<class T>
80class A {
81public:
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
86template<class T>
87class B : public A<T> {
88public:
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
93void foo()
94{
95 B<int> b;
96 b.g1(); // expected-note {{required here}}
97 b.g2(); // expected-note {{required here}}
98}
99
Francois Pichetc8ff9152011-11-25 01:10:54 +0000100}
101
102
103namespace lookup_dependent_base_class_friend {
104
105template <class T>
106class B {
107public:
108 static void g(); // expected-note {{must qualify identifier to find this declaration in dependent base class}}
109};
110
111template <class T>
112class A : public B<T> {
113public:
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
119int main2()
120{
121 A<int> a;
122 foo(a); // expected-note {{requested here}}
123}
124
125}
Francois Pichet4d604d62011-12-03 15:55:29 +0000126
127
128namespace lookup_dependent_base_no_typo_correction {
129
130class C {
131public:
132 int m_hWnd;
133};
134
135template <class T>
136class A : public T {
137public:
138 void f(int hWnd) {
139 m_hWnd = 1;
140 }
141};
142
143template class A<C>;
144
145}