John McCall | 477f2bb | 2016-03-03 06:39:32 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -verify %s |
Arnold Schwaighofer | 4fc955e | 2016-10-12 18:59:24 +0000 | [diff] [blame] | 2 | // RUN: %clang_cc1 -triple x86_64-unknown-windows -fsyntax-only -verify %s |
John McCall | 477f2bb | 2016-03-03 06:39:32 +0000 | [diff] [blame] | 3 | |
| 4 | #define SWIFTCALL __attribute__((swiftcall)) |
| 5 | #define INDIRECT_RESULT __attribute__((swift_indirect_result)) |
| 6 | #define ERROR_RESULT __attribute__((swift_error_result)) |
| 7 | #define CONTEXT __attribute__((swift_context)) |
| 8 | |
| 9 | int notAFunction SWIFTCALL; // expected-warning {{'swiftcall' only applies to function types; type here is 'int'}} |
| 10 | void variadic(int x, ...) SWIFTCALL; // expected-error {{variadic function cannot use swiftcall calling convention}} |
| 11 | void unprototyped() SWIFTCALL; // expected-error {{function with no prototype cannot use the swiftcall calling convention}} |
Michael Kruse | 41dd6ce | 2018-06-25 20:06:13 +0000 | [diff] [blame] | 12 | void multiple_ccs(int x) SWIFTCALL __attribute__((vectorcall)); // expected-error {{vectorcall and swiftcall attributes are not compatible}} |
John McCall | 477f2bb | 2016-03-03 06:39:32 +0000 | [diff] [blame] | 13 | void (*functionPointer)(void) SWIFTCALL; |
| 14 | |
| 15 | void indirect_result_nonswift(INDIRECT_RESULT void *out); // expected-error {{'swift_indirect_result' parameter can only be used with swiftcall calling convention}} |
| 16 | void indirect_result_bad_position(int first, INDIRECT_RESULT void *out) SWIFTCALL; // expected-error {{'swift_indirect_result' parameters must be first parameters of function}} |
| 17 | void indirect_result_bad_type(INDIRECT_RESULT int out) SWIFTCALL; // expected-error {{'swift_indirect_result' parameter must have pointer type; type here is 'int'}} |
| 18 | void indirect_result_single(INDIRECT_RESULT void *out) SWIFTCALL; |
| 19 | void indirect_result_multiple(INDIRECT_RESULT void *out1, INDIRECT_RESULT void *out2) SWIFTCALL; |
| 20 | |
| 21 | void error_result_nonswift(ERROR_RESULT void **error); // expected-error {{'swift_error_result' parameter can only be used with swiftcall calling convention}} expected-error{{'swift_error_result' parameter must follow 'swift_context' parameter}} |
John McCall | 477f2bb | 2016-03-03 06:39:32 +0000 | [diff] [blame] | 22 | void error_result_bad_position2(int first, ERROR_RESULT void **error) SWIFTCALL; // expected-error {{'swift_error_result' parameter must follow 'swift_context' parameter}} |
| 23 | void error_result_bad_type(CONTEXT void *context, ERROR_RESULT int error) SWIFTCALL; // expected-error {{'swift_error_result' parameter must have pointer to unqualified pointer type; type here is 'int'}} |
| 24 | void error_result_bad_type2(CONTEXT void *context, ERROR_RESULT int *error) SWIFTCALL; // expected-error {{'swift_error_result' parameter must have pointer to unqualified pointer type; type here is 'int *'}} |
| 25 | void error_result_okay(int a, int b, CONTEXT void *context, ERROR_RESULT void **error) SWIFTCALL; |
Arnold Schwaighofer | 5bb08d8 | 2016-10-11 20:34:06 +0000 | [diff] [blame] | 26 | void error_result_okay2(CONTEXT void *context, ERROR_RESULT void **error, void *selfType, char **selfWitnessTable) SWIFTCALL; |
John McCall | 477f2bb | 2016-03-03 06:39:32 +0000 | [diff] [blame] | 27 | |
| 28 | void context_nonswift(CONTEXT void *context); // expected-error {{'swift_context' parameter can only be used with swiftcall calling convention}} |
John McCall | 477f2bb | 2016-03-03 06:39:32 +0000 | [diff] [blame] | 29 | void context_bad_type(CONTEXT int context) SWIFTCALL; // expected-error {{'swift_context' parameter must have pointer type; type here is 'int'}} |
| 30 | void context_okay(CONTEXT void *context) SWIFTCALL; |
Arnold Schwaighofer | 5bb08d8 | 2016-10-11 20:34:06 +0000 | [diff] [blame] | 31 | void context_okay2(CONTEXT void *context, void *selfType, char **selfWitnessTable) SWIFTCALL; |