Home | History | Annotate | Download | only in Parser
      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   // FIXME: Re-enable this once MS inline asm stabilizes.
     24 #if 0
     25   __asm {
     26     mov eax, Bit
     27     mov ecx, Base
     28     lock bts [ecx], eax
     29     setc al
     30   };
     31 #endif
     32 }
     33 _inline int foo99() { return 99; }
     34 
     35 void test_ms_alignof_alias() {
     36   unsigned int s = _alignof(int);
     37   s = __builtin_alignof(int);
     38 }
     39 
     40 void *_alloca(int);
     41 
     42 void foo() {
     43   __declspec(align(16)) int *buffer = (int *)_alloca(9);
     44 }
     45 
     46 typedef bool (__stdcall __stdcall *blarg)(int);
     47 
     48 void local_callconv()
     49 {
     50   bool (__stdcall *p)(int);
     51 }
     52 
     53 // Charify extension.
     54 #define FOO(x) #@x
     55 char x = FOO(a);
     56 
     57 typedef enum E { e1 };
     58 
     59 
     60 enum __declspec(deprecated) E2 { i, j, k }; // expected-note {{declared here}}
     61 __declspec(deprecated) enum E3 { a, b, c } e; // expected-note {{declared here}}
     62 
     63 void deprecated_enum_test(void)
     64 {
     65   // Test to make sure the deprecated warning follows the right thing
     66   enum E2 e1;  // expected-warning {{'E2' is deprecated}}
     67   enum E3 e2; // No warning expected, the deprecation follows the variable
     68   enum E3 e3 = e;  // expected-warning {{'e' is deprecated}}
     69 }
     70 
     71 /* Microsoft attribute tests */
     72 [repeatable][source_annotation_attribute( Parameter|ReturnValue )]
     73 struct SA_Post{ SA_Post(); int attr; };
     74 
     75 [returnvalue:SA_Post( attr=1)]
     76 int foo1([SA_Post(attr=1)] void *param);
     77 
     78 
     79 
     80 void ms_intrinsics(int a)
     81 {
     82   __noop();
     83   __assume(a);
     84   __debugbreak();
     85 }
     86 
     87 struct __declspec(frobble) S1 {};	/* expected-warning {{unknown __declspec attribute 'frobble' ignored}} */
     88 struct __declspec(12) S2 {};	/* expected-error {{__declspec attributes must be an identifier or string literal}} */
     89 struct __declspec("testing") S3 {}; /* expected-warning {{__declspec attribute '"testing"' is not supported}} */
     90 
     91 /* Ensure multiple declspec attributes are supported */
     92 struct __declspec(align(8) deprecated) S4 {};
     93 
     94 /* But multiple declspecs must still be legal */
     95 struct __declspec(deprecated frobble "testing") S5 {};  /* expected-warning {{unknown __declspec attribute 'frobble' ignored}} expected-warning {{__declspec attribute '"testing"' is not supported}} */
     96 struct __declspec(unknown(12) deprecated) S6 {};	/* expected-warning {{unknown __declspec attribute 'unknown' ignored}}*/
     97 
     98 struct S7 {
     99 	int foo() { return 12; }
    100 	__declspec(property(get=foo) deprecated) int t; // expected-note {{declared here}}
    101 };
    102 
    103 /* Technically, this is legal (though it does nothing) */
    104 __declspec() void quux( void ) {
    105   struct S7 s;
    106   int i = s.t;	/* expected-warning {{'t' is deprecated}} */
    107 }
    108