2012-10-02 22:26:08 +08:00
// RUN: %clang_cc1 %s -fsyntax-only -triple i386-unknown-unknown -verify
2013-10-09 05:52:56 +08:00
// RUN: %clang_cc1 %s -fsyntax-only -triple i386-unknown-unknown -fms-compatibility -DWIN -verify
2008-03-08 04:04:49 +08:00
2013-07-24 03:30:11 +08:00
void __attribute__ ( ( fastcall ) ) foo ( float * a ) {
2008-03-08 04:04:49 +08:00
}
2013-07-24 03:30:11 +08:00
void __attribute__ ( ( stdcall ) ) bar ( float * a ) {
2008-03-08 04:04:49 +08:00
}
2013-07-24 03:30:11 +08:00
void __attribute__ ( ( fastcall ( 1 ) ) ) baz ( float * a ) { // expected-error {{'fastcall' attribute takes no arguments}}
2008-03-08 04:04:49 +08:00
}
2009-11-04 11:36:09 +08:00
2014-11-04 05:24:50 +08:00
void __attribute__ ( ( fastcall ) ) test0 ( ) {
2009-11-04 11:36:09 +08:00
}
void __attribute__ ( ( fastcall ) ) test1 ( void ) {
}
2013-10-09 05:52:56 +08:00
void __attribute__ ( ( fastcall ) ) test2 ( int a , . . . ) { // expected-warning {{fastcall calling convention ignored on variadic function}}
}
2013-10-10 02:10:25 +08:00
void __attribute__ ( ( stdcall ) ) test3 ( int a , . . . ) { // expected-warning {{stdcall calling convention ignored on variadic function}}
}
void __attribute__ ( ( thiscall ) ) test4 ( int a , . . . ) { // expected-error {{variadic function cannot use thiscall calling convention}}
2009-11-04 11:36:09 +08:00
}
2009-11-10 02:38:53 +08:00
void __attribute__ ( ( cdecl ) ) ctest0 ( ) { }
2013-07-24 03:30:11 +08:00
void __attribute__ ( ( cdecl ( 1 ) ) ) ctest1 ( float x ) { } // expected-error {{'cdecl' attribute takes no arguments}}
2010-02-04 13:44:44 +08:00
void ( __attribute__ ( ( fastcall ) ) * pfoo ) ( float * ) = foo ;
void ( __attribute__ ( ( stdcall ) ) * pbar ) ( float * ) = bar ;
void ( __attribute__ ( ( cdecl ) ) * ptest1 ) ( void ) = test1 ; // expected-warning {{incompatible pointer types}}
void ( * pctest0 ) ( ) = ctest0 ;
void ctest2 ( ) { }
void ( __attribute__ ( ( cdecl ) ) * pctest2 ) ( ) = ctest2 ;
2010-02-06 05:31:56 +08:00
typedef void ( __attribute__ ( ( fastcall ) ) * Handler ) ( float * ) ;
Handler H = foo ;
2013-07-24 03:30:11 +08:00
int __attribute__ ( ( pcs ( " aapcs " , " aapcs " ) ) ) pcs1 ( void ) ; // expected-error {{'pcs' attribute takes one argument}}
int __attribute__ ( ( pcs ( ) ) ) pcs2 ( void ) ; // expected-error {{'pcs' attribute takes one argument}}
2013-09-14 01:48:25 +08:00
int __attribute__ ( ( pcs ( pcs1 ) ) ) pcs3 ( void ) ; / / expected - error { { ' pcs ' attribute requires a string } } \
// expected-error {{invalid PCS type}}
2013-07-30 09:31:03 +08:00
int __attribute__ ( ( pcs ( 0 ) ) ) pcs4 ( void ) ; // expected-error {{'pcs' attribute requires a string}}
2012-10-02 22:26:08 +08:00
/* These are ignored because the target is i386 and not ARM */
2019-03-21 21:30:56 +08:00
int __attribute__ ( ( pcs ( " aapcs " ) ) ) pcs5 ( void ) ; // expected-warning {{'pcs' calling convention ignored for this target}}
int __attribute__ ( ( pcs ( " aapcs-vfp " ) ) ) pcs6 ( void ) ; // expected-warning {{'pcs' calling convention ignored for this target}}
2013-01-29 18:02:16 +08:00
int __attribute__ ( ( pcs ( " foo " ) ) ) pcs7 ( void ) ; // expected-error {{invalid PCS type}}
2012-08-14 21:13:47 +08:00
2019-03-21 21:30:56 +08:00
int __attribute__ ( ( aarch64_vector_pcs ) ) aavpcs ( void ) ; // expected-warning {{'aarch64_vector_pcs' calling convention ignored for this target}}
2018-11-27 00:38:37 +08:00
2010-02-23 14:13:55 +08:00
// PR6361
void ctest3 ( ) ;
void __attribute__ ( ( cdecl ) ) ctest3 ( ) { }
2010-02-24 10:27:18 +08:00
// PR6408
typedef __attribute__ ( ( stdcall ) ) void ( * PROC ) ( ) ;
PROC __attribute__ ( ( cdecl ) ) ctest4 ( const char * x ) { }
2012-12-25 16:53:55 +08:00
void __attribute__ ( ( intel_ocl_bicc ) ) inteloclbifunc ( float * a ) { }
2013-08-28 07:08:25 +08:00
typedef void typedef_fun_t ( int ) ;
typedef_fun_t typedef_fun ; // expected-note {{previous declaration is here}}
void __attribute__ ( ( stdcall ) ) typedef_fun ( int x ) { } // expected-error {{function declared 'stdcall' here was previously declared without calling convention}}
2013-11-19 12:08:34 +08:00
struct type_test { } __attribute__ ( ( stdcall ) ) ; // expected-warning {{'stdcall' attribute only applies to functions and methods}}
2019-03-21 21:30:56 +08:00
void __vectorcall __builtin_unreachable ( ) ; // expected-warning {{vectorcall calling convention ignored on builtin function}}