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