1 // RUN: %clang_cc1 -triple i386-mingw32 -fsyntax-only -verify -fms-extensions -Wno-missing-declarations -x objective-c++ %s 2 __stdcall int func0(); 3 int __stdcall func(); 4 typedef int (__cdecl *tptr)(); 5 void (*__fastcall fastpfunc)(); 6 struct __declspec(uuid("00000000-0000-0000-C000-000000000046")) __declspec(novtable) IUnknown {}; /* expected-warning{{__declspec attribute 'novtable' is not supported}} */ 7 extern __declspec(dllimport) void __stdcall VarR4FromDec(); 8 __declspec(deprecated) __declspec(deprecated) char * __cdecl ltoa( long _Val, char * _DstBuf, int _Radix); 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}} */ 10 typedef __w64 unsigned long ULONG_PTR, *PULONG_PTR; 11 12 void * __ptr64 PtrToPtr64(const void *p) 13 { 14 return((void * __ptr64) (unsigned __int64) (ULONG_PTR)p ); 15 } 16 void * __ptr32 PtrToPtr32(const void *p) 17 { 18 return((void * __ptr32) (unsigned __int32) (ULONG_PTR)p ); 19 } 20 21 void __forceinline InterlockedBitTestAndSet (long *Base, long Bit) 22 { 23 __asm { // expected-warning {{MS-style inline assembly is not supported}} 24 mov eax, Bit 25 mov ecx, Base 26 lock bts [ecx], eax 27 setc al 28 }; 29 } 30 _inline int foo99() { return 99; } 31 32 void test_ms_alignof_alias() { 33 unsigned int s = _alignof(int); 34 s = __builtin_alignof(int); 35 } 36 37 void *_alloca(int); 38 39 void foo() { 40 __declspec(align(16)) int *buffer = (int *)_alloca(9); 41 } 42 43 typedef bool (__stdcall __stdcall *blarg)(int); 44 45 void local_callconv() 46 { 47 bool (__stdcall *p)(int); 48 } 49 50 // Charify extension. 51 #define FOO(x) #@x 52 char x = FOO(a); 53 54 typedef enum E { e1 }; 55 56 57 enum __declspec(deprecated) E2 { i, j, k }; // expected-note {{declared here}} 58 __declspec(deprecated) enum E3 { a, b, c } e; // expected-note {{declared here}} 59 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 } 67 68 /* Microsoft attribute tests */ 69 [repeatable][source_annotation_attribute( Parameter|ReturnValue )] 70 struct SA_Post{ SA_Post(); int attr; }; 71 72 [returnvalue:SA_Post( attr=1)] 73 int foo1([SA_Post(attr=1)] void *param); 74 75 76 77 void ms_intrinsics(int a) 78 { 79 __noop(); 80 __assume(a); 81 __debugbreak(); 82 } 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; // expected-note {{declared here}} 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 } 105