xref: /minix3/external/bsd/llvm/dist/clang/test/SemaCXX/MicrosoftExtensions.cpp (revision f4a2713ac843a11c696ec80c0a5e3e5d80b4d338)
1*f4a2713aSLionel Sambuc // RUN: %clang_cc1 %s -triple i686-pc-win32 -fsyntax-only -Wmicrosoft -Wc++11-extensions -Wno-long-long -verify -fms-extensions -fexceptions -fcxx-exceptions
2*f4a2713aSLionel Sambuc 
3*f4a2713aSLionel Sambuc 
4*f4a2713aSLionel Sambuc // ::type_info is predeclared with forward class declartion
5*f4a2713aSLionel Sambuc void f(const type_info &a);
6*f4a2713aSLionel Sambuc 
7*f4a2713aSLionel Sambuc 
8*f4a2713aSLionel Sambuc // Microsoft doesn't validate exception specification.
9*f4a2713aSLionel Sambuc namespace microsoft_exception_spec {
10*f4a2713aSLionel Sambuc 
11*f4a2713aSLionel Sambuc void foo(); // expected-note {{previous declaration}}
12*f4a2713aSLionel Sambuc void foo() throw(); // expected-warning {{exception specification in declaration does not match previous declaration}}
13*f4a2713aSLionel Sambuc 
14*f4a2713aSLionel Sambuc void r6() throw(...); // expected-note {{previous declaration}}
15*f4a2713aSLionel Sambuc void r6() throw(int); // expected-warning {{exception specification in declaration does not match previous declaration}}
16*f4a2713aSLionel Sambuc 
17*f4a2713aSLionel Sambuc struct Base {
18*f4a2713aSLionel Sambuc   virtual void f2();
19*f4a2713aSLionel Sambuc   virtual void f3() throw(...);
20*f4a2713aSLionel Sambuc };
21*f4a2713aSLionel Sambuc 
22*f4a2713aSLionel Sambuc struct Derived : Base {
23*f4a2713aSLionel Sambuc   virtual void f2() throw(...);
24*f4a2713aSLionel Sambuc   virtual void f3();
25*f4a2713aSLionel Sambuc };
26*f4a2713aSLionel Sambuc 
27*f4a2713aSLionel Sambuc class A {
28*f4a2713aSLionel Sambuc   virtual ~A() throw();  // expected-note {{overridden virtual function is here}}
29*f4a2713aSLionel Sambuc };
30*f4a2713aSLionel Sambuc 
31*f4a2713aSLionel Sambuc class B : public A {
32*f4a2713aSLionel Sambuc   virtual ~B();  // expected-warning {{exception specification of overriding function is more lax than base version}}
33*f4a2713aSLionel Sambuc };
34*f4a2713aSLionel Sambuc 
35*f4a2713aSLionel Sambuc }
36*f4a2713aSLionel Sambuc 
37*f4a2713aSLionel Sambuc // MSVC allows type definition in anonymous union and struct
38*f4a2713aSLionel Sambuc struct A
39*f4a2713aSLionel Sambuc {
40*f4a2713aSLionel Sambuc   union
41*f4a2713aSLionel Sambuc   {
42*f4a2713aSLionel Sambuc     int a;
43*f4a2713aSLionel Sambuc     struct B  // expected-warning {{types declared in an anonymous union are a Microsoft extension}}
44*f4a2713aSLionel Sambuc     {
45*f4a2713aSLionel Sambuc       int c;
46*f4a2713aSLionel Sambuc     } d;
47*f4a2713aSLionel Sambuc 
48*f4a2713aSLionel Sambuc     union C   // expected-warning {{types declared in an anonymous union are a Microsoft extension}}
49*f4a2713aSLionel Sambuc     {
50*f4a2713aSLionel Sambuc       int e;
51*f4a2713aSLionel Sambuc       int ee;
52*f4a2713aSLionel Sambuc     } f;
53*f4a2713aSLionel Sambuc 
54*f4a2713aSLionel Sambuc     typedef int D;  // expected-warning {{types declared in an anonymous union are a Microsoft extension}}
55*f4a2713aSLionel Sambuc     struct F;  // expected-warning {{types declared in an anonymous union are a Microsoft extension}}
56*f4a2713aSLionel Sambuc   };
57*f4a2713aSLionel Sambuc 
58*f4a2713aSLionel Sambuc   struct
59*f4a2713aSLionel Sambuc   {
60*f4a2713aSLionel Sambuc     int a2;
61*f4a2713aSLionel Sambuc 
62*f4a2713aSLionel Sambuc     struct B2  // expected-warning {{types declared in an anonymous struct are a Microsoft extension}}
63*f4a2713aSLionel Sambuc     {
64*f4a2713aSLionel Sambuc       int c2;
65*f4a2713aSLionel Sambuc     } d2;
66*f4a2713aSLionel Sambuc 
67*f4a2713aSLionel Sambuc 	union C2  // expected-warning {{types declared in an anonymous struct are a Microsoft extension}}
68*f4a2713aSLionel Sambuc     {
69*f4a2713aSLionel Sambuc       int e2;
70*f4a2713aSLionel Sambuc       int ee2;
71*f4a2713aSLionel Sambuc     } f2;
72*f4a2713aSLionel Sambuc 
73*f4a2713aSLionel Sambuc     typedef int D2;  // expected-warning {{types declared in an anonymous struct are a Microsoft extension}}
74*f4a2713aSLionel Sambuc     struct F2;  // expected-warning {{types declared in an anonymous struct are a Microsoft extension}}
75*f4a2713aSLionel Sambuc   };
76*f4a2713aSLionel Sambuc };
77*f4a2713aSLionel Sambuc 
78*f4a2713aSLionel Sambuc // __stdcall handling
79*f4a2713aSLionel Sambuc struct M {
80*f4a2713aSLionel Sambuc     int __stdcall addP();
81*f4a2713aSLionel Sambuc     float __stdcall subtractP();
82*f4a2713aSLionel Sambuc };
83*f4a2713aSLionel Sambuc 
84*f4a2713aSLionel Sambuc // __unaligned handling
85*f4a2713aSLionel Sambuc typedef char __unaligned *aligned_type;
86*f4a2713aSLionel Sambuc 
87*f4a2713aSLionel Sambuc 
88*f4a2713aSLionel Sambuc template<typename T> void h1(T (__stdcall M::* const )()) { }
89*f4a2713aSLionel Sambuc 
90*f4a2713aSLionel Sambuc void m1() {
91*f4a2713aSLionel Sambuc   h1<int>(&M::addP);
92*f4a2713aSLionel Sambuc   h1(&M::subtractP);
93*f4a2713aSLionel Sambuc }
94*f4a2713aSLionel Sambuc 
95*f4a2713aSLionel Sambuc 
96*f4a2713aSLionel Sambuc 
97*f4a2713aSLionel Sambuc 
98*f4a2713aSLionel Sambuc 
99*f4a2713aSLionel Sambuc void f(long long);
100*f4a2713aSLionel Sambuc void f(int);
101*f4a2713aSLionel Sambuc 
102*f4a2713aSLionel Sambuc int main()
103*f4a2713aSLionel Sambuc {
104*f4a2713aSLionel Sambuc   // This is an ambiguous call in standard C++.
105*f4a2713aSLionel Sambuc   // This calls f(long long) in Microsoft mode because LL is always signed.
106*f4a2713aSLionel Sambuc   f(0xffffffffffffffffLL);
107*f4a2713aSLionel Sambuc   f(0xffffffffffffffffi64);
108*f4a2713aSLionel Sambuc }
109*f4a2713aSLionel Sambuc 
110*f4a2713aSLionel Sambuc // Enumeration types with a fixed underlying type.
111*f4a2713aSLionel Sambuc const int seventeen = 17;
112*f4a2713aSLionel Sambuc typedef int Int;
113*f4a2713aSLionel Sambuc 
114*f4a2713aSLionel Sambuc struct X0 {
115*f4a2713aSLionel Sambuc   enum E1 : Int { SomeOtherValue } field; // expected-warning{{enumeration types with a fixed underlying type are a C++11 extension}}
116*f4a2713aSLionel Sambuc   enum E1 : seventeen;
117*f4a2713aSLionel Sambuc };
118*f4a2713aSLionel Sambuc 
119*f4a2713aSLionel Sambuc enum : long long {  // expected-warning{{enumeration types with a fixed underlying type are a C++11 extension}}
120*f4a2713aSLionel Sambuc   SomeValue = 0x100000000
121*f4a2713aSLionel Sambuc };
122*f4a2713aSLionel Sambuc 
123*f4a2713aSLionel Sambuc 
124*f4a2713aSLionel Sambuc class AAA {
125*f4a2713aSLionel Sambuc __declspec(dllimport) void f(void) { }
126*f4a2713aSLionel Sambuc void f2(void);
127*f4a2713aSLionel Sambuc };
128*f4a2713aSLionel Sambuc 
129*f4a2713aSLionel Sambuc __declspec(dllimport) void AAA::f2(void) { // expected-error {{dllimport attribute can be applied only to symbol}}
130*f4a2713aSLionel Sambuc 
131*f4a2713aSLionel Sambuc }
132*f4a2713aSLionel Sambuc 
133*f4a2713aSLionel Sambuc 
134*f4a2713aSLionel Sambuc 
135*f4a2713aSLionel Sambuc template <class T>
136*f4a2713aSLionel Sambuc class BB {
137*f4a2713aSLionel Sambuc public:
138*f4a2713aSLionel Sambuc    void f(int g = 10 ); // expected-note {{previous definition is here}}
139*f4a2713aSLionel Sambuc };
140*f4a2713aSLionel Sambuc 
141*f4a2713aSLionel Sambuc template <class T>
142*f4a2713aSLionel Sambuc void BB<T>::f(int g = 0) { } // expected-warning {{redefinition of default argument}}
143*f4a2713aSLionel Sambuc 
144*f4a2713aSLionel Sambuc 
145*f4a2713aSLionel Sambuc 
146*f4a2713aSLionel Sambuc extern void static_func();
147*f4a2713aSLionel Sambuc void static_func(); // expected-note {{previous declaration is here}}
148*f4a2713aSLionel Sambuc 
149*f4a2713aSLionel Sambuc 
150*f4a2713aSLionel Sambuc static void static_func() // expected-warning {{static declaration of 'static_func' follows non-static declaration}}
151*f4a2713aSLionel Sambuc {
152*f4a2713aSLionel Sambuc 
153*f4a2713aSLionel Sambuc }
154*f4a2713aSLionel Sambuc 
155*f4a2713aSLionel Sambuc long function_prototype(int a);
156*f4a2713aSLionel Sambuc long (*function_ptr)(int a);
157*f4a2713aSLionel Sambuc 
158*f4a2713aSLionel Sambuc void function_to_voidptr_conv() {
159*f4a2713aSLionel Sambuc    void *a1 = function_prototype;
160*f4a2713aSLionel Sambuc    void *a2 = &function_prototype;
161*f4a2713aSLionel Sambuc    void *a3 = function_ptr;
162*f4a2713aSLionel Sambuc }
163*f4a2713aSLionel Sambuc 
164*f4a2713aSLionel Sambuc 
165*f4a2713aSLionel Sambuc void pointer_to_integral_type_conv(char* ptr) {
166*f4a2713aSLionel Sambuc    char ch = (char)ptr;
167*f4a2713aSLionel Sambuc    short sh = (short)ptr;
168*f4a2713aSLionel Sambuc    ch = (char)ptr;
169*f4a2713aSLionel Sambuc    sh = (short)ptr;
170*f4a2713aSLionel Sambuc 
171*f4a2713aSLionel Sambuc    // These are valid C++.
172*f4a2713aSLionel Sambuc    bool b = (bool)ptr;
173*f4a2713aSLionel Sambuc    b = static_cast<bool>(ptr);
174*f4a2713aSLionel Sambuc 
175*f4a2713aSLionel Sambuc    // This is bad.
176*f4a2713aSLionel Sambuc    b = reinterpret_cast<bool>(ptr); // expected-error {{cast from pointer to smaller type 'bool' loses information}}
177*f4a2713aSLionel Sambuc }
178*f4a2713aSLionel Sambuc 
179*f4a2713aSLionel Sambuc namespace friend_as_a_forward_decl {
180*f4a2713aSLionel Sambuc 
181*f4a2713aSLionel Sambuc class A {
182*f4a2713aSLionel Sambuc   class Nested {
183*f4a2713aSLionel Sambuc     friend class B;
184*f4a2713aSLionel Sambuc     B* b;
185*f4a2713aSLionel Sambuc   };
186*f4a2713aSLionel Sambuc   B* b;
187*f4a2713aSLionel Sambuc };
188*f4a2713aSLionel Sambuc B* global_b;
189*f4a2713aSLionel Sambuc 
190*f4a2713aSLionel Sambuc 
191*f4a2713aSLionel Sambuc void f()
192*f4a2713aSLionel Sambuc {
193*f4a2713aSLionel Sambuc   class Local {
194*f4a2713aSLionel Sambuc     friend class Z;
195*f4a2713aSLionel Sambuc     Z* b;
196*f4a2713aSLionel Sambuc   };
197*f4a2713aSLionel Sambuc   Z* b;
198*f4a2713aSLionel Sambuc }
199*f4a2713aSLionel Sambuc 
200*f4a2713aSLionel Sambuc }
201*f4a2713aSLionel Sambuc 
202*f4a2713aSLionel Sambuc struct PR11150 {
203*f4a2713aSLionel Sambuc   class X {
204*f4a2713aSLionel Sambuc     virtual void f() = 0;
205*f4a2713aSLionel Sambuc   };
206*f4a2713aSLionel Sambuc 
207*f4a2713aSLionel Sambuc   int array[__is_abstract(X)? 1 : -1];
208*f4a2713aSLionel Sambuc };
209*f4a2713aSLionel Sambuc 
210*f4a2713aSLionel Sambuc void f() { int __except = 0; }
211*f4a2713aSLionel Sambuc 
212*f4a2713aSLionel Sambuc void ::f(); // expected-warning{{extra qualification on member 'f'}}
213*f4a2713aSLionel Sambuc 
214*f4a2713aSLionel Sambuc class C {
215*f4a2713aSLionel Sambuc   C::C(); // expected-warning{{extra qualification on member 'C'}}
216*f4a2713aSLionel Sambuc };
217*f4a2713aSLionel Sambuc 
218*f4a2713aSLionel Sambuc struct StructWithProperty {
219*f4a2713aSLionel Sambuc   __declspec(property(get=GetV)) int V1;
220*f4a2713aSLionel Sambuc   __declspec(property(put=SetV)) int V2;
221*f4a2713aSLionel Sambuc   __declspec(property(get=GetV, put=SetV_NotExist)) int V3;
222*f4a2713aSLionel Sambuc   __declspec(property(get=GetV_NotExist, put=SetV)) int V4;
223*f4a2713aSLionel Sambuc   __declspec(property(get=GetV, put=SetV)) int V5;
224*f4a2713aSLionel Sambuc 
225*f4a2713aSLionel Sambuc   int GetV() { return 123; }
226*f4a2713aSLionel Sambuc   void SetV(int i) {}
227*f4a2713aSLionel Sambuc };
228*f4a2713aSLionel Sambuc void TestProperty() {
229*f4a2713aSLionel Sambuc   StructWithProperty sp;
230*f4a2713aSLionel Sambuc   int i = sp.V2; // expected-error{{no getter defined for property 'V2'}}
231*f4a2713aSLionel Sambuc   sp.V1 = 12; // expected-error{{no setter defined for property 'V1'}}
232*f4a2713aSLionel Sambuc   int j = sp.V4; // expected-error{{no member named 'GetV_NotExist' in 'StructWithProperty'}} expected-error{{cannot find suitable getter for property 'V4'}}
233*f4a2713aSLionel Sambuc   sp.V3 = 14; // expected-error{{no member named 'SetV_NotExist' in 'StructWithProperty'}} expected-error{{cannot find suitable setter for property 'V3'}}
234*f4a2713aSLionel Sambuc   int k = sp.V5;
235*f4a2713aSLionel Sambuc   sp.V5 = k++;
236*f4a2713aSLionel Sambuc }
237*f4a2713aSLionel Sambuc 
238*f4a2713aSLionel Sambuc /* 4 tests for PseudoObject, begin */
239*f4a2713aSLionel Sambuc struct SP1
240*f4a2713aSLionel Sambuc {
241*f4a2713aSLionel Sambuc   bool operator()() { return true; }
242*f4a2713aSLionel Sambuc };
243*f4a2713aSLionel Sambuc struct SP2
244*f4a2713aSLionel Sambuc {
245*f4a2713aSLionel Sambuc   __declspec(property(get=GetV)) SP1 V;
246*f4a2713aSLionel Sambuc   SP1 GetV() { return SP1(); }
247*f4a2713aSLionel Sambuc };
248*f4a2713aSLionel Sambuc void TestSP2() {
249*f4a2713aSLionel Sambuc   SP2 sp2;
250*f4a2713aSLionel Sambuc   bool b = sp2.V();
251*f4a2713aSLionel Sambuc }
252*f4a2713aSLionel Sambuc 
253*f4a2713aSLionel Sambuc struct SP3 {
254*f4a2713aSLionel Sambuc   template <class T>
255*f4a2713aSLionel Sambuc   void f(T t) {}
256*f4a2713aSLionel Sambuc };
257*f4a2713aSLionel Sambuc template <class T>
258*f4a2713aSLionel Sambuc struct SP4
259*f4a2713aSLionel Sambuc {
260*f4a2713aSLionel Sambuc   __declspec(property(get=GetV)) int V;
261*f4a2713aSLionel Sambuc   int GetV() { return 123; }
262*f4a2713aSLionel Sambuc   void f() { SP3 s2; s2.f(V); }
263*f4a2713aSLionel Sambuc };
264*f4a2713aSLionel Sambuc void TestSP4() {
265*f4a2713aSLionel Sambuc   SP4<int> s;
266*f4a2713aSLionel Sambuc   s.f();
267*f4a2713aSLionel Sambuc }
268*f4a2713aSLionel Sambuc 
269*f4a2713aSLionel Sambuc template <class T>
270*f4a2713aSLionel Sambuc struct SP5
271*f4a2713aSLionel Sambuc {
272*f4a2713aSLionel Sambuc   __declspec(property(get=GetV)) T V;
273*f4a2713aSLionel Sambuc   int GetV() { return 123; }
274*f4a2713aSLionel Sambuc   void f() { int *p = new int[V]; }
275*f4a2713aSLionel Sambuc };
276*f4a2713aSLionel Sambuc 
277*f4a2713aSLionel Sambuc template <class T>
278*f4a2713aSLionel Sambuc struct SP6
279*f4a2713aSLionel Sambuc {
280*f4a2713aSLionel Sambuc public:
281*f4a2713aSLionel Sambuc   __declspec(property(get=GetV)) T V;
282*f4a2713aSLionel Sambuc   T GetV() { return 123; }
283*f4a2713aSLionel Sambuc   void f() { int t = V; }
284*f4a2713aSLionel Sambuc };
285*f4a2713aSLionel Sambuc void TestSP6() {
286*f4a2713aSLionel Sambuc   SP6<int> c;
287*f4a2713aSLionel Sambuc   c.f();
288*f4a2713aSLionel Sambuc }
289*f4a2713aSLionel Sambuc /* 4 tests for PseudoObject, end */
290*f4a2713aSLionel Sambuc 
291*f4a2713aSLionel Sambuc // Property access: explicit, implicit, with Qualifier
292*f4a2713aSLionel Sambuc struct SP7 {
293*f4a2713aSLionel Sambuc   __declspec(property(get=GetV, put=SetV)) int V;
294*f4a2713aSLionel Sambuc   int GetV() { return 123; }
295*f4a2713aSLionel Sambuc   void SetV(int v) {}
296*f4a2713aSLionel Sambuc 
297*f4a2713aSLionel Sambuc   void ImplicitAccess() { int i = V; V = i; }
298*f4a2713aSLionel Sambuc   void ExplicitAccess() { int i = this->V; this->V = i; }
299*f4a2713aSLionel Sambuc };
300*f4a2713aSLionel Sambuc struct SP8: public SP7 {
301*f4a2713aSLionel Sambuc   void AccessWithQualifier() { int i = SP7::V; SP7::V = i; }
302*f4a2713aSLionel Sambuc };
303*f4a2713aSLionel Sambuc 
304*f4a2713aSLionel Sambuc // Property usage
305*f4a2713aSLionel Sambuc template <class T>
306*f4a2713aSLionel Sambuc struct SP9 {
307*f4a2713aSLionel Sambuc   __declspec(property(get=GetV, put=SetV)) T V;
308*f4a2713aSLionel Sambuc   T GetV() { return 0; }
309*f4a2713aSLionel Sambuc   void SetV(T v) {}
310*f4a2713aSLionel Sambuc   void f() { V = this->V; V < this->V; }
311*f4a2713aSLionel Sambuc   void g() { V++; }
312*f4a2713aSLionel Sambuc   void h() { V*=2; }
313*f4a2713aSLionel Sambuc };
314*f4a2713aSLionel Sambuc struct SP10 {
315*f4a2713aSLionel Sambuc   SP10(int v) {}
316*f4a2713aSLionel Sambuc   bool operator<(const SP10& v) { return true; }
317*f4a2713aSLionel Sambuc   SP10 operator*(int v) { return *this; }
318*f4a2713aSLionel Sambuc   SP10 operator+(int v) { return *this; }
319*f4a2713aSLionel Sambuc   SP10& operator=(const SP10& v) { return *this; }
320*f4a2713aSLionel Sambuc };
321*f4a2713aSLionel Sambuc void TestSP9() {
322*f4a2713aSLionel Sambuc   SP9<int> c;
323*f4a2713aSLionel Sambuc   int i = c.V; // Decl initializer
324*f4a2713aSLionel Sambuc   i = c.V; // Binary op operand
325*f4a2713aSLionel Sambuc   c.SetV(c.V); // CallExpr arg
326*f4a2713aSLionel Sambuc   int *p = new int[c.V + 1]; // Array size
327*f4a2713aSLionel Sambuc   p[c.V] = 1; // Array index
328*f4a2713aSLionel Sambuc 
329*f4a2713aSLionel Sambuc   c.V = 123; // Setter
330*f4a2713aSLionel Sambuc 
331*f4a2713aSLionel Sambuc   c.V++; // Unary op operand
332*f4a2713aSLionel Sambuc   c.V *= 2; // Unary op operand
333*f4a2713aSLionel Sambuc 
334*f4a2713aSLionel Sambuc   SP9<int*> c2;
335*f4a2713aSLionel Sambuc   c2.V[0] = 123; // Array
336*f4a2713aSLionel Sambuc 
337*f4a2713aSLionel Sambuc   SP9<SP10> c3;
338*f4a2713aSLionel Sambuc   c3.f(); // Overloaded binary op operand
339*f4a2713aSLionel Sambuc   c3.g(); // Overloaded incdec op operand
340*f4a2713aSLionel Sambuc   c3.h(); // Overloaded unary op operand
341*f4a2713aSLionel Sambuc }
342*f4a2713aSLionel Sambuc 
343*f4a2713aSLionel Sambuc union u {
344*f4a2713aSLionel Sambuc   int *i1;
345*f4a2713aSLionel Sambuc   int &i2;  // expected-warning {{union member 'i2' has reference type 'int &', which is a Microsoft extension}}
346*f4a2713aSLionel Sambuc };
347*f4a2713aSLionel Sambuc 
348*f4a2713aSLionel Sambuc // Property getter using reference.
349*f4a2713aSLionel Sambuc struct SP11 {
350*f4a2713aSLionel Sambuc   __declspec(property(get=GetV)) int V;
351*f4a2713aSLionel Sambuc   int _v;
352*f4a2713aSLionel Sambuc   int& GetV() { return _v; }
353*f4a2713aSLionel Sambuc   void UseV();
354*f4a2713aSLionel Sambuc   void TakePtr(int *) {}
355*f4a2713aSLionel Sambuc   void TakeRef(int &) {}
356*f4a2713aSLionel Sambuc   void TakeVal(int) {}
357*f4a2713aSLionel Sambuc };
358*f4a2713aSLionel Sambuc 
359*f4a2713aSLionel Sambuc void SP11::UseV() {
360*f4a2713aSLionel Sambuc   TakePtr(&V);
361*f4a2713aSLionel Sambuc   TakeRef(V);
362*f4a2713aSLionel Sambuc   TakeVal(V);
363*f4a2713aSLionel Sambuc }
364*f4a2713aSLionel Sambuc 
365*f4a2713aSLionel Sambuc struct StructWithUnnamedMember {
366*f4a2713aSLionel Sambuc   __declspec(property(get=GetV)) int : 10; // expected-error {{anonymous property is not supported}}
367*f4a2713aSLionel Sambuc };
368*f4a2713aSLionel Sambuc 
369*f4a2713aSLionel Sambuc namespace rdar14250378 {
370*f4a2713aSLionel Sambuc   class Bar {};
371*f4a2713aSLionel Sambuc 
372*f4a2713aSLionel Sambuc   namespace NyNamespace {
373*f4a2713aSLionel Sambuc     class Foo {
374*f4a2713aSLionel Sambuc     public:
375*f4a2713aSLionel Sambuc       Bar* EnsureBar();
376*f4a2713aSLionel Sambuc     };
377*f4a2713aSLionel Sambuc 
378*f4a2713aSLionel Sambuc     class Baz : public Foo {
379*f4a2713aSLionel Sambuc     public:
380*f4a2713aSLionel Sambuc       friend class Bar;
381*f4a2713aSLionel Sambuc     };
382*f4a2713aSLionel Sambuc 
383*f4a2713aSLionel Sambuc     Bar* Foo::EnsureBar() {
384*f4a2713aSLionel Sambuc       return 0;
385*f4a2713aSLionel Sambuc     }
386*f4a2713aSLionel Sambuc   }
387*f4a2713aSLionel Sambuc }
388*f4a2713aSLionel Sambuc 
389*f4a2713aSLionel Sambuc // expected-error@+1 {{'sealed' keyword not permitted with interface types}}
390*f4a2713aSLionel Sambuc __interface InterfaceWithSealed sealed {
391*f4a2713aSLionel Sambuc };
392*f4a2713aSLionel Sambuc 
393*f4a2713aSLionel Sambuc struct SomeBase {
394*f4a2713aSLionel Sambuc   virtual void OverrideMe();
395*f4a2713aSLionel Sambuc 
396*f4a2713aSLionel Sambuc   // expected-note@+2 {{overridden virtual function is here}}
397*f4a2713aSLionel Sambuc   // expected-warning@+1 {{'sealed' keyword is a Microsoft extension}}
398*f4a2713aSLionel Sambuc   virtual void SealedFunction() sealed;
399*f4a2713aSLionel Sambuc };
400*f4a2713aSLionel Sambuc 
401*f4a2713aSLionel Sambuc // expected-note@+2 {{'SealedType' declared here}}
402*f4a2713aSLionel Sambuc // expected-warning@+1 {{'sealed' keyword is a Microsoft extension}}
403*f4a2713aSLionel Sambuc struct SealedType sealed : SomeBase {
404*f4a2713aSLionel Sambuc   // expected-error@+1 {{declaration of 'SealedFunction' overrides a 'sealed' function}}
405*f4a2713aSLionel Sambuc   virtual void SealedFunction();
406*f4a2713aSLionel Sambuc 
407*f4a2713aSLionel Sambuc   // expected-warning@+1 {{'override' keyword is a C++11 extension}}
408*f4a2713aSLionel Sambuc   virtual void OverrideMe() override;
409*f4a2713aSLionel Sambuc };
410*f4a2713aSLionel Sambuc 
411*f4a2713aSLionel Sambuc // expected-error@+1 {{base 'SealedType' is marked 'sealed'}}
412*f4a2713aSLionel Sambuc struct InheritFromSealed : SealedType {};
413