• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // RUN: %clang_cc1 -triple i386-mingw32 -fsyntax-only -Wno-missing-declarations -verify -fms-extensions  %s
2 __stdcall int func0(void);
3 int __stdcall func(void);
4 typedef int (__cdecl *tptr)(void);
5 void (*__fastcall fastpfunc)(void);
6 extern __declspec(dllimport) void __stdcall VarR4FromDec(void);
7 __declspec(deprecated) __declspec(deprecated) char * __cdecl ltoa( long _Val, char * _DstBuf, int _Radix);
8 __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}} */
9 typedef __w64 unsigned long ULONG_PTR, *PULONG_PTR;
10 
PtrToPtr64(const void * p)11 void * __ptr64 PtrToPtr64(const void *p) {
12   return((void * __ptr64) (unsigned __int64) (ULONG_PTR)p );
13 }
14 
PtrToPtr32(const void * p)15 void * __ptr32 PtrToPtr32(const void *p) {
16   return((void * __ptr32) (unsigned __int32) (ULONG_PTR)p );
17 }
18 
19 /* Both inline and __forceinline is OK. */
pr8264(void)20 inline void __forceinline pr8264(void) {}
pr8264_1(void)21 __forceinline void inline pr8264_1(void) {}
pr8264_2(void)22 void inline __forceinline pr8264_2(void) {}
pr8264_3(void)23 void __forceinline inline pr8264_3(void) {}
24 /* But duplicate __forceinline causes warning. */
pr8264_4(void)25 void __forceinline __forceinline pr8264_4(void) {  /* expected-warning{{duplicate '__forceinline' declaration specifier}} */
26 }
27 
foo99(void)28 _inline int foo99(void) { return 99; }
29 
test_ms_alignof_alias(void)30 void test_ms_alignof_alias(void) {
31   unsigned int s = _alignof(int);
32   s = __builtin_alignof(int);
33 }
34 
35 /* Charify extension. */
36 #define FOO(x) #@x
37 char x = FOO(a);
38 
39 typedef enum E { e1 };
40 
41 enum __declspec(deprecated) E2 { i, j, k }; /* expected-note {{'E2' has been explicitly marked deprecated here}} */
42 __declspec(deprecated) enum E3 { a, b, c } e; /* expected-note {{'e' has been explicitly marked deprecated here}} */
43 
deprecated_enum_test(void)44 void deprecated_enum_test(void) {
45   /* Test to make sure the deprecated warning follows the right thing */
46   enum E2 e1;  /* expected-warning {{'E2' is deprecated}} */
47   enum E3 e2; /* No warning expected, the deprecation follows the variable */
48   enum E3 e3 = e;  /* expected-warning {{'e' is deprecated}} */
49 }
50 
51 /* Microsoft attribute tests */
52 [returnvalue:SA_Post( attr=1)]
53 int foo1([SA_Post(attr=1)] void *param);
54 
ms_intrinsics(int a)55 void ms_intrinsics(int a) {
56   __noop();
57   __assume(a);
58   __debugbreak();
59 }
60 
61 struct __declspec(frobble) S1 {};	/* expected-warning {{__declspec attribute 'frobble' is not supported}} */
62 struct __declspec(12) S2 {};	/* expected-error {{__declspec attributes must be an identifier or string literal}} */
63 struct __declspec("testing") S3 {}; /* expected-warning {{__declspec attribute '"testing"' is not supported}} */
64 
65 /* declspecs with arguments cannot have an empty argument list, even if the
66    arguments are optional. */
67 __declspec(deprecated()) void dep_func_test(void); /* expected-error {{parentheses must be omitted if 'deprecated' attribute's argument list is empty}} */
68 __declspec(deprecated) void dep_func_test2(void);
69 __declspec(deprecated("")) void dep_func_test3(void);
70 
71 /* Ensure multiple declspec attributes are supported */
72 struct __declspec(align(8) deprecated) S4 {};
73 
74 /* But multiple declspecs must still be legal */
75 struct __declspec(deprecated frobble "testing") S5 {};  /* expected-warning {{__declspec attribute 'frobble' is not supported}} expected-warning {{__declspec attribute '"testing"' is not supported}} */
76 struct __declspec(unknown(12) deprecated) S6 {};	/* expected-warning {{__declspec attribute 'unknown' is not supported}}*/
77 
78 int * __sptr psp;
79 int * __uptr pup;
80 /* Either ordering is acceptable */
81 int * __ptr32 __sptr psp32;
82 int * __ptr32 __uptr pup32;
83 int * __sptr __ptr64 psp64;
84 int * __uptr __ptr64 pup64;
85 
86 /* Legal to have nested pointer attributes */
87 int * __sptr * __ptr32 ppsp32;
88