2010-12-20 11:51:03 +08:00
// RUN: %clang_cc1 -triple i386-mingw32 -fsyntax-only -verify -fms-extensions -Wno-missing-declarations -x objective-c++ %s
2008-12-25 22:16:32 +08:00
__stdcall int func0 ( ) ;
int __stdcall func ( ) ;
typedef int ( __cdecl * tptr ) ( ) ;
void ( * __fastcall fastpfunc ) ( ) ;
2012-06-20 06:09:27 +08:00
struct __declspec ( uuid ( " 00000000-0000-0000-C000-000000000046 " ) ) __declspec ( novtable ) IUnknown { } ; /* expected-warning{{__declspec attribute 'novtable' is not supported}} */
2008-12-25 22:16:32 +08:00
extern __declspec ( dllimport ) void __stdcall VarR4FromDec ( ) ;
__declspec ( deprecated ) __declspec ( deprecated ) char * __cdecl ltoa ( long _Val , char * _DstBuf , int _Radix ) ;
2013-05-05 00:58:37 +08:00
__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}} */
2008-12-25 22:41:26 +08:00
typedef __w64 unsigned long ULONG_PTR , * PULONG_PTR ;
2011-08-25 08:36:46 +08:00
2008-12-25 22:41:26 +08:00
void * __ptr64 PtrToPtr64 ( const void * p )
{
2012-05-23 05:28:12 +08:00
return ( ( void * __ptr64 ) ( unsigned __int64 ) ( ULONG_PTR ) p ) ;
2008-12-25 22:41:26 +08:00
}
2011-08-25 08:36:46 +08:00
void * __ptr32 PtrToPtr32 ( const void * p )
{
2012-05-23 05:28:12 +08:00
return ( ( void * __ptr32 ) ( unsigned __int32 ) ( ULONG_PTR ) p ) ;
2011-08-25 08:36:46 +08:00
}
2012-12-06 07:08:09 +08:00
void __forceinline InterlockedBitTestAndSet ( long * Base , long Bit )
{
2013-01-29 18:02:16 +08:00
// FIXME: Re-enable this once MS inline asm stabilizes.
#if 0
2013-01-23 02:18:22 +08:00
__asm {
2012-12-06 07:08:09 +08:00
mov eax , Bit
mov ecx , Base
lock bts [ ecx ] , eax
setc al
} ;
2013-01-29 18:02:16 +08:00
# endif
2012-12-06 07:08:09 +08:00
}
2010-10-06 21:02:48 +08:00
_inline int foo99 ( ) { return 99 ; }
2008-12-25 22:41:26 +08:00
2012-05-17 04:04:05 +08:00
void test_ms_alignof_alias ( ) {
unsigned int s = _alignof ( int ) ;
s = __builtin_alignof ( int ) ;
}
2009-01-07 03:34:12 +08:00
void * _alloca ( int ) ;
void foo ( ) {
2009-09-09 23:08:12 +08:00
__declspec ( align ( 16 ) ) int * buffer = ( int * ) _alloca ( 9 ) ;
2009-01-07 03:34:12 +08:00
}
2009-01-10 08:48:18 +08:00
typedef bool ( __stdcall __stdcall * blarg ) ( int ) ;
2009-12-24 03:15:27 +08:00
2010-09-29 07:35:09 +08:00
void local_callconv ( )
{
bool ( __stdcall * p ) ( int ) ;
}
2009-12-24 03:15:27 +08:00
// Charify extension.
# define FOO(x) #@x
char x = FOO ( a ) ;
2010-07-16 23:18:19 +08:00
typedef enum E { e1 } ;
2010-09-08 20:20:18 +08:00
2012-08-09 05:52:41 +08:00
enum __declspec ( deprecated ) E2 { i , j , k } ; // expected-note {{declared here}}
__declspec ( deprecated ) enum E3 { a , b , c } e ; // expected-note {{declared here}}
2010-12-20 09:41:49 +08:00
2012-03-15 08:20:05 +08:00
void deprecated_enum_test ( void )
{
// Test to make sure the deprecated warning follows the right thing
enum E2 e1 ; // expected-warning {{'E2' is deprecated}}
enum E3 e2 ; // No warning expected, the deprecation follows the variable
enum E3 e3 = e ; // expected-warning {{'e' is deprecated}}
}
2010-10-11 20:00:10 +08:00
2010-10-11 20:59:39 +08:00
/* Microsoft attribute tests */
[ repeatable ] [ source_annotation_attribute ( Parameter | ReturnValue ) ]
struct SA_Post { SA_Post ( ) ; int attr ; } ;
2012-06-20 06:09:27 +08:00
[ returnvalue : SA_Post ( attr = 1 ) ]
2010-10-11 20:59:39 +08:00
int foo1 ( [ SA_Post ( attr = 1 ) ] void * param ) ;
2010-10-11 20:00:10 +08:00
void ms_intrinsics ( int a )
{
__noop ( ) ;
__assume ( a ) ;
2011-07-10 22:15:07 +08:00
__debugbreak ( ) ;
2010-10-11 20:00:10 +08:00
}
2012-06-20 06:09:27 +08:00
struct __declspec ( frobble ) S1 { } ; /* expected-warning {{unknown __declspec attribute 'frobble' ignored}} */
struct __declspec ( 12 ) S2 { } ; /* expected-error {{__declspec attributes must be an identifier or string literal}} */
struct __declspec ( " testing " ) S3 { } ; /* expected-warning {{__declspec attribute '"testing"' is not supported}} */
/* Ensure multiple declspec attributes are supported */
struct __declspec ( align ( 8 ) deprecated ) S4 { } ;
/* But multiple declspecs must still be legal */
struct __declspec ( deprecated frobble " testing " ) S5 { } ; /* expected-warning {{unknown __declspec attribute 'frobble' ignored}} expected-warning {{__declspec attribute '"testing"' is not supported}} */
struct __declspec ( unknown ( 12 ) deprecated ) S6 { } ; /* expected-warning {{unknown __declspec attribute 'unknown' ignored}}*/
struct S7 {
int foo ( ) { return 12 ; }
2012-08-09 05:52:41 +08:00
__declspec ( property ( get = foo ) deprecated ) int t ; // expected-note {{declared here}}
2012-06-20 06:09:27 +08:00
} ;
/* Technically, this is legal (though it does nothing) */
__declspec ( ) void quux ( void ) {
struct S7 s ;
int i = s . t ; /* expected-warning {{'t' is deprecated}} */
}
2013-05-23 07:25:32 +08:00
int * __sptr psp ;
int * __uptr pup ;
/* Either ordering is acceptable */
int * __ptr32 __sptr psp32 ;
int * __ptr32 __uptr pup32 ;
int * __sptr __ptr64 psp64 ;
int * __uptr __ptr64 pup64 ;
/* Legal to have nested pointer attributes */
int * __sptr * __ptr32 ppsp32 ;