blob: 7703999d67ce6543398d8a7edb3f3fdb7f996377 [file] [log] [blame]
Francois Pichet913b7bf2010-12-20 03:51:03 +00001// RUN: %clang_cc1 -triple i386-mingw32 -fsyntax-only -verify -fms-extensions -Wno-missing-declarations -x objective-c++ %s
Steve Naroff239f0732008-12-25 14:16:32 +00002__stdcall int func0();
3int __stdcall func();
4typedef int (__cdecl *tptr)();
5void (*__fastcall fastpfunc)();
Aaron Ballmanfc685ac2012-06-19 22:09:27 +00006struct __declspec(uuid("00000000-0000-0000-C000-000000000046")) __declspec(novtable) IUnknown {}; /* expected-warning{{__declspec attribute 'novtable' is not supported}} */
Steve Naroff239f0732008-12-25 14:16:32 +00007extern __declspec(dllimport) void __stdcall VarR4FromDec();
8__declspec(deprecated) __declspec(deprecated) char * __cdecl ltoa( long _Val, char * _DstBuf, int _Radix);
Aaron Ballmanfc685ac2012-06-19 22:09:27 +00009__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 Naroff86bc6cf2008-12-25 14:41:26 +000010typedef __w64 unsigned long ULONG_PTR, *PULONG_PTR;
Francois Pichet58fd97a2011-08-25 00:36:46 +000011
Steve Naroff86bc6cf2008-12-25 14:41:26 +000012void * __ptr64 PtrToPtr64(const void *p)
13{
John McCallc052dbb2012-05-22 21:28:12 +000014 return((void * __ptr64) (unsigned __int64) (ULONG_PTR)p );
Steve Naroff86bc6cf2008-12-25 14:41:26 +000015}
Francois Pichet58fd97a2011-08-25 00:36:46 +000016void * __ptr32 PtrToPtr32(const void *p)
17{
John McCallc052dbb2012-05-22 21:28:12 +000018 return((void * __ptr32) (unsigned __int32) (ULONG_PTR)p );
Francois Pichet58fd97a2011-08-25 00:36:46 +000019}
20
Mike Stumpd1969d82009-07-22 00:43:08 +000021void __forceinline InterlockedBitTestAndSet (long *Base, long Bit)
Steve Naroff86bc6cf2008-12-25 14:41:26 +000022{
Chad Rosier52e4ed92012-06-20 18:28:37 +000023 __asm { // expected-warning {{MS-style inline assembly is not supported}}
Mike Stump1eb44332009-09-09 15:08:12 +000024 mov eax, Bit
25 mov ecx, Base
26 lock bts [ecx], eax
27 setc al
28 };
Steve Naroff86bc6cf2008-12-25 14:41:26 +000029}
Francois Pichet229ca4a2010-10-06 13:02:48 +000030_inline int foo99() { return 99; }
Steve Naroff86bc6cf2008-12-25 14:41:26 +000031
Douglas Gregorda8d8c22012-05-16 20:04:05 +000032void test_ms_alignof_alias() {
33 unsigned int s = _alignof(int);
34 s = __builtin_alignof(int);
35}
36
Steve Naroff47f52092009-01-06 19:34:12 +000037void *_alloca(int);
38
39void foo() {
Mike Stump1eb44332009-09-09 15:08:12 +000040 __declspec(align(16)) int *buffer = (int *)_alloca(9);
Steve Naroff47f52092009-01-06 19:34:12 +000041}
Douglas Gregor5a2f5d32009-01-10 00:48:18 +000042
43typedef bool (__stdcall __stdcall *blarg)(int);
Chris Lattner66335222009-12-23 19:15:27 +000044
Chris Lattner6229c8e2010-09-28 23:35:09 +000045void local_callconv()
46{
47 bool (__stdcall *p)(int);
48}
Chris Lattner66335222009-12-23 19:15:27 +000049
50// Charify extension.
51#define FOO(x) #@x
52char x = FOO(a);
53
Douglas Gregor0c99ec62010-07-16 15:18:19 +000054typedef enum E { e1 };
Francois Pichet01b7c302010-09-08 12:20:18 +000055
56
Eli Friedmanc3b23082012-08-08 21:52:41 +000057enum __declspec(deprecated) E2 { i, j, k }; // expected-note {{declared here}}
58__declspec(deprecated) enum E3 { a, b, c } e; // expected-note {{declared here}}
Francois Pichetd3d3be92010-12-20 01:41:49 +000059
Aaron Ballman0e3c9892012-03-15 00:20:05 +000060void 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 Pichetb2419462010-10-11 12:00:10 +000067
Francois Pichet334d47e2010-10-11 12:59:39 +000068/* Microsoft attribute tests */
69[repeatable][source_annotation_attribute( Parameter|ReturnValue )]
70struct SA_Post{ SA_Post(); int attr; };
71
Aaron Ballmanfc685ac2012-06-19 22:09:27 +000072[returnvalue:SA_Post( attr=1)]
Francois Pichet334d47e2010-10-11 12:59:39 +000073int foo1([SA_Post(attr=1)] void *param);
74
75
Francois Pichetb2419462010-10-11 12:00:10 +000076
77void ms_intrinsics(int a)
78{
79 __noop();
80 __assume(a);
Francois Pichet699f9b12011-07-10 14:15:07 +000081 __debugbreak();
Francois Pichetb2419462010-10-11 12:00:10 +000082}
Aaron Ballmanfc685ac2012-06-19 22:09:27 +000083
84struct __declspec(frobble) S1 {}; /* expected-warning {{unknown __declspec attribute 'frobble' ignored}} */
85struct __declspec(12) S2 {}; /* expected-error {{__declspec attributes must be an identifier or string literal}} */
86struct __declspec("testing") S3 {}; /* expected-warning {{__declspec attribute '"testing"' is not supported}} */
87
88/* Ensure multiple declspec attributes are supported */
89struct __declspec(align(8) deprecated) S4 {};
90
91/* But multiple declspecs must still be legal */
92struct __declspec(deprecated frobble "testing") S5 {}; /* expected-warning {{unknown __declspec attribute 'frobble' ignored}} expected-warning {{__declspec attribute '"testing"' is not supported}} */
93struct __declspec(unknown(12) deprecated) S6 {}; /* expected-warning {{unknown __declspec attribute 'unknown' ignored}}*/
94
95struct S7 {
96 int foo() { return 12; }
Eli Friedmanc3b23082012-08-08 21:52:41 +000097 __declspec(property(get=foo) deprecated) int t; // expected-note {{declared here}}
Aaron Ballmanfc685ac2012-06-19 22:09:27 +000098};
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}