1*f4a2713aSLionel Sambuc // RUN: %clang_cc1 %s -fsyntax-only -triple i386-unknown-unknown -verify 2*f4a2713aSLionel Sambuc // RUN: %clang_cc1 %s -fsyntax-only -triple i386-unknown-unknown -fms-compatibility -DWIN -verify 3*f4a2713aSLionel Sambuc 4*f4a2713aSLionel Sambuc void __attribute__((fastcall)) foo(float *a) { 5*f4a2713aSLionel Sambuc } 6*f4a2713aSLionel Sambuc 7*f4a2713aSLionel Sambuc void __attribute__((stdcall)) bar(float *a) { 8*f4a2713aSLionel Sambuc } 9*f4a2713aSLionel Sambuc 10*f4a2713aSLionel Sambuc void __attribute__((fastcall(1))) baz(float *a) { // expected-error {{'fastcall' attribute takes no arguments}} 11*f4a2713aSLionel Sambuc } 12*f4a2713aSLionel Sambuc 13*f4a2713aSLionel Sambuc void __attribute__((fastcall)) test0() { // expected-error {{function with no prototype cannot use fastcall calling convention}} 14*f4a2713aSLionel Sambuc } 15*f4a2713aSLionel Sambuc 16*f4a2713aSLionel Sambuc void __attribute__((fastcall)) test1(void) { 17*f4a2713aSLionel Sambuc } 18*f4a2713aSLionel Sambuc 19*f4a2713aSLionel Sambuc void __attribute__((fastcall)) test2(int a, ...) { // expected-warning {{fastcall calling convention ignored on variadic function}} 20*f4a2713aSLionel Sambuc } 21*f4a2713aSLionel Sambuc void __attribute__((stdcall)) test3(int a, ...) { // expected-warning {{stdcall calling convention ignored on variadic function}} 22*f4a2713aSLionel Sambuc } 23*f4a2713aSLionel Sambuc void __attribute__((thiscall)) test4(int a, ...) { // expected-error {{variadic function cannot use thiscall calling convention}} 24*f4a2713aSLionel Sambuc } 25*f4a2713aSLionel Sambuc 26*f4a2713aSLionel Sambuc void __attribute__((cdecl)) ctest0() {} 27*f4a2713aSLionel Sambuc 28*f4a2713aSLionel Sambuc void __attribute__((cdecl(1))) ctest1(float x) {} // expected-error {{'cdecl' attribute takes no arguments}} 29*f4a2713aSLionel Sambuc 30*f4a2713aSLionel Sambuc void (__attribute__((fastcall)) *pfoo)(float*) = foo; 31*f4a2713aSLionel Sambuc 32*f4a2713aSLionel Sambuc void (__attribute__((stdcall)) *pbar)(float*) = bar; 33*f4a2713aSLionel Sambuc 34*f4a2713aSLionel Sambuc void (__attribute__((cdecl)) *ptest1)(void) = test1; // expected-warning {{incompatible pointer types}} 35*f4a2713aSLionel Sambuc 36*f4a2713aSLionel Sambuc void (*pctest0)() = ctest0; 37*f4a2713aSLionel Sambuc 38*f4a2713aSLionel Sambuc void ctest2() {} 39*f4a2713aSLionel Sambuc void (__attribute__((cdecl)) *pctest2)() = ctest2; 40*f4a2713aSLionel Sambuc 41*f4a2713aSLionel Sambuc typedef void (__attribute__((fastcall)) *Handler) (float *); 42*f4a2713aSLionel Sambuc Handler H = foo; 43*f4a2713aSLionel Sambuc 44*f4a2713aSLionel Sambuc int __attribute__((pcs("aapcs", "aapcs"))) pcs1(void); // expected-error {{'pcs' attribute takes one argument}} 45*f4a2713aSLionel Sambuc int __attribute__((pcs())) pcs2(void); // expected-error {{'pcs' attribute takes one argument}} 46*f4a2713aSLionel Sambuc int __attribute__((pcs(pcs1))) pcs3(void); // expected-error {{'pcs' attribute requires a string}} \ 47*f4a2713aSLionel Sambuc // expected-error {{invalid PCS type}} 48*f4a2713aSLionel Sambuc int __attribute__((pcs(0))) pcs4(void); // expected-error {{'pcs' attribute requires a string}} 49*f4a2713aSLionel Sambuc /* These are ignored because the target is i386 and not ARM */ 50*f4a2713aSLionel Sambuc int __attribute__((pcs("aapcs"))) pcs5(void); // expected-warning {{calling convention 'pcs' ignored for this target}} 51*f4a2713aSLionel Sambuc int __attribute__((pcs("aapcs-vfp"))) pcs6(void); // expected-warning {{calling convention 'pcs' ignored for this target}} 52*f4a2713aSLionel Sambuc int __attribute__((pcs("foo"))) pcs7(void); // expected-error {{invalid PCS type}} 53*f4a2713aSLionel Sambuc 54*f4a2713aSLionel Sambuc // PR6361 55*f4a2713aSLionel Sambuc void ctest3(); 56*f4a2713aSLionel Sambuc void __attribute__((cdecl)) ctest3() {} 57*f4a2713aSLionel Sambuc 58*f4a2713aSLionel Sambuc // PR6408 59*f4a2713aSLionel Sambuc typedef __attribute__((stdcall)) void (*PROC)(); 60*f4a2713aSLionel Sambuc PROC __attribute__((cdecl)) ctest4(const char *x) {} 61*f4a2713aSLionel Sambuc 62*f4a2713aSLionel Sambuc void __attribute__((pnaclcall)) pnaclfunc(float *a) {} // expected-warning {{calling convention 'pnaclcall' ignored for this target}} 63*f4a2713aSLionel Sambuc 64*f4a2713aSLionel Sambuc void __attribute__((intel_ocl_bicc)) inteloclbifunc(float *a) {} 65*f4a2713aSLionel Sambuc 66*f4a2713aSLionel Sambuc typedef void typedef_fun_t(int); 67*f4a2713aSLionel Sambuc typedef_fun_t typedef_fun; // expected-note {{previous declaration is here}} 68*f4a2713aSLionel Sambuc void __attribute__((stdcall)) typedef_fun(int x) { } // expected-error {{function declared 'stdcall' here was previously declared without calling convention}} 69