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 | ed35fd1 | 2012-06-19 13:49:26 +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 | ed35fd1 | 2012-06-19 13:49:26 +0000 | [diff] [blame^] | 9 | __declspec(noalias) __declspec(restrict) void * __cdecl xxx( void * _Memory ); /* 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 | |
Mike Stump | d1969d8 | 2009-07-22 00:43:08 +0000 | [diff] [blame] | 21 | void __forceinline InterlockedBitTestAndSet (long *Base, long Bit) |
Steve Naroff | 86bc6cf | 2008-12-25 14:41:26 +0000 | [diff] [blame] | 22 | { |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 23 | __asm { |
| 24 | mov eax, Bit |
| 25 | mov ecx, Base |
| 26 | lock bts [ecx], eax |
| 27 | setc al |
| 28 | }; |
Steve Naroff | 86bc6cf | 2008-12-25 14:41:26 +0000 | [diff] [blame] | 29 | } |
Francois Pichet | 229ca4a | 2010-10-06 13:02:48 +0000 | [diff] [blame] | 30 | _inline int foo99() { return 99; } |
Steve Naroff | 86bc6cf | 2008-12-25 14:41:26 +0000 | [diff] [blame] | 31 | |
Douglas Gregor | da8d8c2 | 2012-05-16 20:04:05 +0000 | [diff] [blame] | 32 | void test_ms_alignof_alias() { |
| 33 | unsigned int s = _alignof(int); |
| 34 | s = __builtin_alignof(int); |
| 35 | } |
| 36 | |
Steve Naroff | 47f5209 | 2009-01-06 19:34:12 +0000 | [diff] [blame] | 37 | void *_alloca(int); |
| 38 | |
| 39 | void foo() { |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 40 | __declspec(align(16)) int *buffer = (int *)_alloca(9); |
Steve Naroff | 47f5209 | 2009-01-06 19:34:12 +0000 | [diff] [blame] | 41 | } |
Douglas Gregor | 5a2f5d3 | 2009-01-10 00:48:18 +0000 | [diff] [blame] | 42 | |
| 43 | typedef bool (__stdcall __stdcall *blarg)(int); |
Chris Lattner | 6633522 | 2009-12-23 19:15:27 +0000 | [diff] [blame] | 44 | |
Chris Lattner | 6229c8e | 2010-09-28 23:35:09 +0000 | [diff] [blame] | 45 | void local_callconv() |
| 46 | { |
| 47 | bool (__stdcall *p)(int); |
| 48 | } |
Chris Lattner | 6633522 | 2009-12-23 19:15:27 +0000 | [diff] [blame] | 49 | |
| 50 | // Charify extension. |
| 51 | #define FOO(x) #@x |
| 52 | char x = FOO(a); |
| 53 | |
Douglas Gregor | 0c99ec6 | 2010-07-16 15:18:19 +0000 | [diff] [blame] | 54 | typedef enum E { e1 }; |
Francois Pichet | 01b7c30 | 2010-09-08 12:20:18 +0000 | [diff] [blame] | 55 | |
| 56 | |
Aaron Ballman | 6454a02 | 2012-03-01 04:09:28 +0000 | [diff] [blame] | 57 | enum __declspec(deprecated) E2 { i, j, k }; |
| 58 | __declspec(deprecated) enum E3 { a, b, c } e; |
Francois Pichet | d3d3be9 | 2010-12-20 01:41:49 +0000 | [diff] [blame] | 59 | |
Aaron Ballman | 0e3c989 | 2012-03-15 00:20:05 +0000 | [diff] [blame] | 60 | void deprecated_enum_test(void) |
| 61 | { |
| 62 | // Test to make sure the deprecated warning follows the right thing |
| 63 | enum E2 e1; // expected-warning {{'E2' is deprecated}} |
| 64 | enum E3 e2; // No warning expected, the deprecation follows the variable |
| 65 | enum E3 e3 = e; // expected-warning {{'e' is deprecated}} |
| 66 | } |
Francois Pichet | b241946 | 2010-10-11 12:00:10 +0000 | [diff] [blame] | 67 | |
Francois Pichet | 334d47e | 2010-10-11 12:59:39 +0000 | [diff] [blame] | 68 | /* Microsoft attribute tests */ |
| 69 | [repeatable][source_annotation_attribute( Parameter|ReturnValue )] |
| 70 | struct SA_Post{ SA_Post(); int attr; }; |
| 71 | |
Aaron Ballman | ed35fd1 | 2012-06-19 13:49:26 +0000 | [diff] [blame^] | 72 | [returnvalue:SA_Post( attr=1)] |
Francois Pichet | 334d47e | 2010-10-11 12:59:39 +0000 | [diff] [blame] | 73 | int foo1([SA_Post(attr=1)] void *param); |
| 74 | |
| 75 | |
Francois Pichet | b241946 | 2010-10-11 12:00:10 +0000 | [diff] [blame] | 76 | |
| 77 | void ms_intrinsics(int a) |
| 78 | { |
| 79 | __noop(); |
| 80 | __assume(a); |
Francois Pichet | 699f9b1 | 2011-07-10 14:15:07 +0000 | [diff] [blame] | 81 | __debugbreak(); |
Francois Pichet | b241946 | 2010-10-11 12:00:10 +0000 | [diff] [blame] | 82 | } |
Aaron Ballman | ed35fd1 | 2012-06-19 13:49:26 +0000 | [diff] [blame^] | 83 | |
| 84 | struct __declspec(frobble) S1 {}; /* expected-warning {{unknown __declspec attribute 'frobble' ignored}} */ |
| 85 | struct __declspec(12) S2 {}; /* expected-error {{__declspec attributes must be an identifier or string literal}} */ |
| 86 | struct __declspec("testing") S3 {}; /* expected-warning {{__declspec attribute '"testing"' is not supported}} */ |
| 87 | |
| 88 | /* Ensure multiple declspec attributes are supported */ |
| 89 | struct __declspec(align(8) deprecated) S4 {}; |
| 90 | |
| 91 | /* But multiple declspecs must still be legal */ |
| 92 | struct __declspec(deprecated frobble "testing") S5 {}; /* expected-warning {{unknown __declspec attribute 'frobble' ignored}} expected-warning {{__declspec attribute '"testing"' is not supported}} */ |
| 93 | struct __declspec(unknown(12) deprecated) S6 {}; /* expected-warning {{unknown __declspec attribute 'unknown' ignored}}*/ |
| 94 | |
| 95 | struct S7 { |
| 96 | int foo() { return 12; } |
| 97 | __declspec(property(get=foo) deprecated) int t; |
| 98 | }; |
| 99 | |
| 100 | /* Technically, this is legal (though it does nothing) */ |
| 101 | __declspec() void quux( void ) { |
| 102 | struct S7 s; |
| 103 | int i = s.t; /* expected-warning {{'t' is deprecated}} */ |
| 104 | } |