MicrosoftExtensions.c revision ecea19f00a911c50dc20fe94e548f488ded47adb
1// RUN: %clang_cc1 -triple i386-mingw32 -fsyntax-only -verify -fms-extensions -Wno-unused-value -Wno-missing-declarations -x objective-c++ %s
2__stdcall int func0();
3int __stdcall func();
4typedef int (__cdecl *tptr)();
5void (*__fastcall fastpfunc)();
6struct __declspec(uuid("00000000-0000-0000-C000-000000000046")) __declspec(novtable) IUnknown {};
7extern __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 );
10typedef __w64 unsigned long ULONG_PTR, *PULONG_PTR;
11void * __ptr64 PtrToPtr64(const void *p)
12{
13  return((void * __ptr64) (unsigned __int64) (ULONG_PTR)p );
14}
15void __forceinline InterlockedBitTestAndSet (long *Base, long Bit)
16{
17  __asm {
18    mov eax, Bit
19    mov ecx, Base
20    lock bts [ecx], eax
21    setc al
22  };
23}
24_inline int foo99() { return 99; }
25
26void *_alloca(int);
27
28void foo() {
29  __declspec(align(16)) int *buffer = (int *)_alloca(9);
30}
31
32typedef bool (__stdcall __stdcall *blarg)(int);
33
34void local_callconv()
35{
36  bool (__stdcall *p)(int);
37}
38
39// Charify extension.
40#define FOO(x) #@x
41char x = FOO(a);
42
43typedef enum E { e1 };
44
45
46void uuidof_test1()
47{
48  __uuidof(0);  // expected-error {{you need to include <guiddef.h> before using the '__uuidof' operator}}
49}
50
51typedef struct _GUID
52{
53    unsigned long  Data1;
54    unsigned short Data2;
55    unsigned short Data3;
56    unsigned char  Data4[8];
57} GUID;
58struct __declspec(uuid("00000000-0000-0000-3231-000000000046")) A { };
59struct __declspec(uuid("00000000-0000-0000-1234-000000000047")) B { };
60class C {};
61
62void uuidof_test2()
63{
64  A* a = new A;
65  B b;
66  __uuidof(A);
67  __uuidof(*a);
68  __uuidof(B);
69  __uuidof(&b);
70  _uuidof(0);
71
72   // FIXME, this must not compile
73  _uuidof(1);
74   // FIXME, this must not compile
75  _uuidof(C);
76
77   C c;
78   // FIXME, this must not compile
79  _uuidof(c);
80
81  &_uuidof(0);
82}
83
84/* Microsoft attribute tests */
85[repeatable][source_annotation_attribute( Parameter|ReturnValue )]
86struct SA_Post{ SA_Post(); int attr; };
87
88[returnvalue:SA_Post( attr=1)]
89int foo1([SA_Post(attr=1)] void *param);
90
91
92
93void ms_intrinsics(int a)
94{
95  __noop();
96  __assume(a);
97
98}
99