Francois Pichet | 913b7bf | 2010-12-20 03:51:03 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -triple i386-mingw32 -fsyntax-only -verify -fms-extensions -Wno-missing-declarations -x objective-c++ %s |
Steve Naroff | 239f073 | 2008-12-25 14:16:32 +0000 | [diff] [blame] | 2 | __stdcall int func0(); |
| 3 | int __stdcall func(); |
| 4 | typedef int (__cdecl *tptr)(); |
| 5 | void (*__fastcall fastpfunc)(); |
Aaron Ballman | fc685ac | 2012-06-19 22:09:27 +0000 | [diff] [blame] | 6 | struct __declspec(uuid("00000000-0000-0000-C000-000000000046")) __declspec(novtable) IUnknown {}; /* expected-warning{{__declspec attribute 'novtable' is not supported}} */ |
Steve Naroff | 239f073 | 2008-12-25 14:16:32 +0000 | [diff] [blame] | 7 | extern __declspec(dllimport) void __stdcall VarR4FromDec(); |
| 8 | __declspec(deprecated) __declspec(deprecated) char * __cdecl ltoa( long _Val, char * _DstBuf, int _Radix); |
Aaron Ballman | 3ce0de6 | 2013-05-04 16:58:37 +0000 | [diff] [blame] | 9 | __declspec(safebuffers) __declspec(noalias) __declspec(restrict) void * __cdecl xxx( void * _Memory ); /* expected-warning{{__declspec attribute 'safebuffers' is not supported}} expected-warning{{__declspec attribute 'noalias' is not supported}} expected-warning{{__declspec attribute 'restrict' is not supported}} */ |
Steve Naroff | 86bc6cf | 2008-12-25 14:41:26 +0000 | [diff] [blame] | 10 | typedef __w64 unsigned long ULONG_PTR, *PULONG_PTR; |
Francois Pichet | 58fd97a | 2011-08-25 00:36:46 +0000 | [diff] [blame] | 11 | |
Steve Naroff | 86bc6cf | 2008-12-25 14:41:26 +0000 | [diff] [blame] | 12 | void * __ptr64 PtrToPtr64(const void *p) |
| 13 | { |
John McCall | c052dbb | 2012-05-22 21:28:12 +0000 | [diff] [blame] | 14 | return((void * __ptr64) (unsigned __int64) (ULONG_PTR)p ); |
Steve Naroff | 86bc6cf | 2008-12-25 14:41:26 +0000 | [diff] [blame] | 15 | } |
Francois Pichet | 58fd97a | 2011-08-25 00:36:46 +0000 | [diff] [blame] | 16 | void * __ptr32 PtrToPtr32(const void *p) |
| 17 | { |
John McCall | c052dbb | 2012-05-22 21:28:12 +0000 | [diff] [blame] | 18 | return((void * __ptr32) (unsigned __int32) (ULONG_PTR)p ); |
Francois Pichet | 58fd97a | 2011-08-25 00:36:46 +0000 | [diff] [blame] | 19 | } |
| 20 | |
Chad Rosier | e23fbf1 | 2012-12-05 23:08:09 +0000 | [diff] [blame] | 21 | void __forceinline InterlockedBitTestAndSet (long *Base, long Bit) |
| 22 | { |
Richard Smith | d03de6a | 2013-01-29 10:02:16 +0000 | [diff] [blame] | 23 | // FIXME: Re-enable this once MS inline asm stabilizes. |
| 24 | #if 0 |
Chad Rosier | c666cf4 | 2013-01-22 18:18:22 +0000 | [diff] [blame] | 25 | __asm { |
Chad Rosier | e23fbf1 | 2012-12-05 23:08:09 +0000 | [diff] [blame] | 26 | mov eax, Bit |
| 27 | mov ecx, Base |
| 28 | lock bts [ecx], eax |
| 29 | setc al |
| 30 | }; |
Richard Smith | d03de6a | 2013-01-29 10:02:16 +0000 | [diff] [blame] | 31 | #endif |
Chad Rosier | e23fbf1 | 2012-12-05 23:08:09 +0000 | [diff] [blame] | 32 | } |
Francois Pichet | 229ca4a | 2010-10-06 13:02:48 +0000 | [diff] [blame] | 33 | _inline int foo99() { return 99; } |
Steve Naroff | 86bc6cf | 2008-12-25 14:41:26 +0000 | [diff] [blame] | 34 | |
Douglas Gregor | da8d8c2 | 2012-05-16 20:04:05 +0000 | [diff] [blame] | 35 | void test_ms_alignof_alias() { |
| 36 | unsigned int s = _alignof(int); |
| 37 | s = __builtin_alignof(int); |
| 38 | } |
| 39 | |
Steve Naroff | 47f5209 | 2009-01-06 19:34:12 +0000 | [diff] [blame] | 40 | void *_alloca(int); |
| 41 | |
| 42 | void foo() { |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 43 | __declspec(align(16)) int *buffer = (int *)_alloca(9); |
Steve Naroff | 47f5209 | 2009-01-06 19:34:12 +0000 | [diff] [blame] | 44 | } |
Douglas Gregor | 5a2f5d3 | 2009-01-10 00:48:18 +0000 | [diff] [blame] | 45 | |
| 46 | typedef bool (__stdcall __stdcall *blarg)(int); |
Chris Lattner | 6633522 | 2009-12-23 19:15:27 +0000 | [diff] [blame] | 47 | |
Chris Lattner | 6229c8e | 2010-09-28 23:35:09 +0000 | [diff] [blame] | 48 | void local_callconv() |
| 49 | { |
| 50 | bool (__stdcall *p)(int); |
| 51 | } |
Chris Lattner | 6633522 | 2009-12-23 19:15:27 +0000 | [diff] [blame] | 52 | |
| 53 | // Charify extension. |
| 54 | #define FOO(x) #@x |
| 55 | char x = FOO(a); |
| 56 | |
Douglas Gregor | 0c99ec6 | 2010-07-16 15:18:19 +0000 | [diff] [blame] | 57 | typedef enum E { e1 }; |
Francois Pichet | 01b7c30 | 2010-09-08 12:20:18 +0000 | [diff] [blame] | 58 | |
| 59 | |
Eli Friedman | c3b2308 | 2012-08-08 21:52:41 +0000 | [diff] [blame] | 60 | enum __declspec(deprecated) E2 { i, j, k }; // expected-note {{declared here}} |
| 61 | __declspec(deprecated) enum E3 { a, b, c } e; // expected-note {{declared here}} |
Francois Pichet | d3d3be9 | 2010-12-20 01:41:49 +0000 | [diff] [blame] | 62 | |
Aaron Ballman | 0e3c989 | 2012-03-15 00:20:05 +0000 | [diff] [blame] | 63 | void deprecated_enum_test(void) |
| 64 | { |
| 65 | // Test to make sure the deprecated warning follows the right thing |
| 66 | enum E2 e1; // expected-warning {{'E2' is deprecated}} |
| 67 | enum E3 e2; // No warning expected, the deprecation follows the variable |
| 68 | enum E3 e3 = e; // expected-warning {{'e' is deprecated}} |
| 69 | } |
Francois Pichet | b241946 | 2010-10-11 12:00:10 +0000 | [diff] [blame] | 70 | |
Francois Pichet | 334d47e | 2010-10-11 12:59:39 +0000 | [diff] [blame] | 71 | /* Microsoft attribute tests */ |
| 72 | [repeatable][source_annotation_attribute( Parameter|ReturnValue )] |
| 73 | struct SA_Post{ SA_Post(); int attr; }; |
| 74 | |
Aaron Ballman | fc685ac | 2012-06-19 22:09:27 +0000 | [diff] [blame] | 75 | [returnvalue:SA_Post( attr=1)] |
Francois Pichet | 334d47e | 2010-10-11 12:59:39 +0000 | [diff] [blame] | 76 | int foo1([SA_Post(attr=1)] void *param); |
| 77 | |
| 78 | |
Francois Pichet | b241946 | 2010-10-11 12:00:10 +0000 | [diff] [blame] | 79 | |
| 80 | void ms_intrinsics(int a) |
| 81 | { |
| 82 | __noop(); |
| 83 | __assume(a); |
Francois Pichet | 699f9b1 | 2011-07-10 14:15:07 +0000 | [diff] [blame] | 84 | __debugbreak(); |
Francois Pichet | b241946 | 2010-10-11 12:00:10 +0000 | [diff] [blame] | 85 | } |
Aaron Ballman | fc685ac | 2012-06-19 22:09:27 +0000 | [diff] [blame] | 86 | |
| 87 | struct __declspec(frobble) S1 {}; /* expected-warning {{unknown __declspec attribute 'frobble' ignored}} */ |
| 88 | struct __declspec(12) S2 {}; /* expected-error {{__declspec attributes must be an identifier or string literal}} */ |
| 89 | struct __declspec("testing") S3 {}; /* expected-warning {{__declspec attribute '"testing"' is not supported}} */ |
| 90 | |
| 91 | /* Ensure multiple declspec attributes are supported */ |
| 92 | struct __declspec(align(8) deprecated) S4 {}; |
| 93 | |
| 94 | /* But multiple declspecs must still be legal */ |
| 95 | struct __declspec(deprecated frobble "testing") S5 {}; /* expected-warning {{unknown __declspec attribute 'frobble' ignored}} expected-warning {{__declspec attribute '"testing"' is not supported}} */ |
| 96 | struct __declspec(unknown(12) deprecated) S6 {}; /* expected-warning {{unknown __declspec attribute 'unknown' ignored}}*/ |
| 97 | |
| 98 | struct S7 { |
| 99 | int foo() { return 12; } |
Eli Friedman | c3b2308 | 2012-08-08 21:52:41 +0000 | [diff] [blame] | 100 | __declspec(property(get=foo) deprecated) int t; // expected-note {{declared here}} |
Aaron Ballman | fc685ac | 2012-06-19 22:09:27 +0000 | [diff] [blame] | 101 | }; |
| 102 | |
| 103 | /* Technically, this is legal (though it does nothing) */ |
| 104 | __declspec() void quux( void ) { |
| 105 | struct S7 s; |
| 106 | int i = s.t; /* expected-warning {{'t' is deprecated}} */ |
| 107 | } |
Aaron Ballman | aa9df09 | 2013-05-22 23:25:32 +0000 | [diff] [blame] | 108 | |
| 109 | int * __sptr psp; |
| 110 | int * __uptr pup; |
| 111 | /* Either ordering is acceptable */ |
| 112 | int * __ptr32 __sptr psp32; |
| 113 | int * __ptr32 __uptr pup32; |
| 114 | int * __sptr __ptr64 psp64; |
| 115 | int * __uptr __ptr64 pup64; |
| 116 | |
| 117 | /* Legal to have nested pointer attributes */ |
| 118 | int * __sptr * __ptr32 ppsp32; |