2014-07-07 04:04:10 +08:00
// RUN: %clang_cc1 -triple i386-mingw32 -fsyntax-only -Wno-missing-declarations -verify -fms-extensions %s
__stdcall int func0 ( void ) ;
int __stdcall func ( void ) ;
typedef int ( __cdecl * tptr ) ( void ) ;
void ( * __fastcall fastpfunc ) ( void ) ;
extern __declspec ( dllimport ) void __stdcall VarR4FromDec ( void ) ;
2008-12-25 22:16:32 +08:00
__declspec ( deprecated ) __declspec ( deprecated ) char * __cdecl ltoa ( long _Val , char * _DstBuf , int _Radix ) ;
2015-07-21 06:51:52 +08:00
__declspec ( safebuffers ) __declspec ( noalias ) __declspec ( restrict ) void * __cdecl xxx ( void * _Memory ) ; /* expected-warning{{__declspec attribute 'safebuffers' 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
2014-07-07 04:04:10 +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
}
2014-07-07 04:04:10 +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
}
2014-07-07 04:04:10 +08:00
/* Both inline and __forceinline is OK. */
inline void __forceinline pr8264 ( void ) { }
__forceinline void inline pr8264_1 ( void ) { }
void inline __forceinline pr8264_2 ( void ) { }
void __forceinline inline pr8264_3 ( void ) { }
/* But duplicate __forceinline causes warning. */
void __forceinline __forceinline pr8264_4 ( void ) { /* expected-warning{{duplicate '__forceinline' declaration specifier}} */
2013-11-13 14:57:53 +08:00
}
2014-07-07 04:04:10 +08:00
_inline int foo99 ( void ) { return 99 ; }
2008-12-25 22:41:26 +08:00
2014-07-07 04:04:10 +08:00
void test_ms_alignof_alias ( void ) {
2012-05-17 04:04:05 +08:00
unsigned int s = _alignof ( int ) ;
s = __builtin_alignof ( int ) ;
}
2014-07-07 04:04:10 +08:00
/* Charify extension. */
2009-12-24 03:15:27 +08:00
# define FOO(x) #@x
char x = FOO ( a ) ;
2016-04-02 03:02:20 +08:00
# define HASHAT #@
# define MISSING_ARG(x) #@
/* expected-error@-1 {{'#@' is not followed by a macro parameter}} */
2009-12-24 03:15:27 +08:00
2010-07-16 23:18:19 +08:00
typedef enum E { e1 } ;
2010-09-08 20:20:18 +08:00
2014-07-07 04:04:10 +08:00
enum __declspec ( deprecated ) E2 { i , j , k } ; /* expected-note {{'E2' has been explicitly marked deprecated here}} */
__declspec ( deprecated ) enum E3 { a , b , c } e ; /* expected-note {{'e' has been explicitly marked deprecated here}} */
2010-09-08 20:20:18 +08:00
2014-07-07 04:04:10 +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}} */
2012-03-15 08:20:05 +08:00
}
2010-10-11 20:00:10 +08:00
2010-10-11 20:59:39 +08:00
/* Microsoft attribute tests */
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 ) ;
2015-06-16 04:57:04 +08:00
[ unbalanced ( attribute ) /* expected-note {{to match this '['}} */
void f ( void ) ; /* expected-error {{expected ']'}} */
2014-07-07 04:04:10 +08:00
void ms_intrinsics ( int a ) {
2010-10-11 20:00:10 +08:00
__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
2014-04-01 02:18:43 +08:00
struct __declspec ( frobble ) S1 { } ; /* expected-warning {{__declspec attribute 'frobble' is not supported}} */
2012-06-20 06:09:27 +08:00
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}} */
2014-04-15 00:44:26 +08:00
/* declspecs with arguments cannot have an empty argument list, even if the
arguments are optional . */
2014-04-15 08:36:39 +08:00
__declspec ( deprecated ( ) ) void dep_func_test ( void ) ; /* expected-error {{parentheses must be omitted if 'deprecated' attribute's argument list is empty}} */
2014-04-15 00:44:26 +08:00
__declspec ( deprecated ) void dep_func_test2 ( void ) ;
__declspec ( deprecated ( " " ) ) void dep_func_test3 ( void ) ;
2012-06-20 06:09:27 +08:00
/* Ensure multiple declspec attributes are supported */
struct __declspec ( align ( 8 ) deprecated ) S4 { } ;
/* But multiple declspecs must still be legal */
2014-04-01 02:18:43 +08:00
struct __declspec ( deprecated frobble " testing " ) S5 { } ; /* expected-warning {{__declspec attribute 'frobble' is not supported}} expected-warning {{__declspec attribute '"testing"' is not supported}} */
struct __declspec ( unknown ( 12 ) deprecated ) S6 { } ; /* expected-warning {{__declspec attribute 'unknown' is not supported}}*/
2012-06-20 06:09:27 +08:00
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 ;
2014-12-05 07:31:08 +08:00
// Ignored type qualifiers after comma in declarator lists
typedef int ignored_quals_dummy1 , const volatile __ptr32 __ptr64 __w64 __unaligned __sptr __uptr ignored_quals1 ; // expected-warning {{qualifiers after comma in declarator list are ignored}}
2022-02-08 04:28:35 +08:00
typedef void ( * ignored_quals_dummy2 ) ( void ) , __fastcall ignored_quals2 ; // expected-warning {{qualifiers after comma in declarator list are ignored}}
typedef void ( * ignored_quals_dummy3 ) ( void ) , __stdcall ignored_quals3 ; // expected-warning {{qualifiers after comma in declarator list are ignored}}
typedef void ( * ignored_quals_dummy4 ) ( void ) , __thiscall ignored_quals4 ; // expected-warning {{qualifiers after comma in declarator list are ignored}}
typedef void ( * ignored_quals_dummy5 ) ( void ) , __cdecl ignored_quals5 ; // expected-warning {{qualifiers after comma in declarator list are ignored}}
typedef void ( * ignored_quals_dummy6 ) ( void ) , __vectorcall ignored_quals6 ; // expected-warning {{qualifiers after comma in declarator list are ignored}}
2015-04-19 15:53:29 +08:00
__declspec ( align ( 16 ) ) struct align_before_key1 { } ;
__declspec ( align ( 16 ) ) struct align_before_key2 { } align_before_key2_var ;
__declspec ( align ( 16 ) ) struct align_before_key3 { } * align_before_key3_var ;
_Static_assert ( __alignof ( struct align_before_key1 ) = = 16 , " " ) ;
_Static_assert ( __alignof ( struct align_before_key2 ) = = 16 , " " ) ;
_Static_assert ( __alignof ( struct align_before_key3 ) = = 16 , " " ) ;
2016-08-02 00:39:29 +08:00
void PR28782 ( int i ) {
foo :
int n ;
switch ( i ) {
case 0 :
int m ;
}
}