diff options
author | Arnold Schwaighofer <aschwaighofer@apple.com> | 2016-10-11 20:34:06 +0000 |
---|---|---|
committer | Arnold Schwaighofer <aschwaighofer@apple.com> | 2016-10-11 20:34:06 +0000 |
commit | 5bb08d8f5ab7bfbb40fa101507f2a5e676d643cf (patch) | |
tree | 2f2538ea1f8c736bc55ce3d4a48404cf4bf55e8a | |
parent | 5d2c510cf64f1348f452acda7e5d1a35f08fd4eb (diff) | |
download | bcm5719-llvm-5bb08d8f5ab7bfbb40fa101507f2a5e676d643cf.tar.gz bcm5719-llvm-5bb08d8f5ab7bfbb40fa101507f2a5e676d643cf.zip |
Swift Calling Convention: Parameters are allowed after the
swift_error/swift_context parameter
We need to be able to decelare witness functions which append the self type and
the self witness tables at the end of the parameter list.
rdar://28720996
llvm-svn: 283933
-rw-r--r-- | clang/lib/Sema/SemaType.cpp | 20 | ||||
-rw-r--r-- | clang/test/Sema/attr-swiftcall.c | 4 | ||||
-rw-r--r-- | clang/test/SemaCXX/attr-swiftcall.cpp | 4 |
3 files changed, 8 insertions, 20 deletions
diff --git a/clang/lib/Sema/SemaType.cpp b/clang/lib/Sema/SemaType.cpp index b0f18fd1bdc..0f2ec79ba38 100644 --- a/clang/lib/Sema/SemaType.cpp +++ b/clang/lib/Sema/SemaType.cpp @@ -2400,28 +2400,16 @@ static void checkExtParameterInfos(Sema &S, ArrayRef<QualType> paramTypes, } continue; - // swift_context parameters must be the last parameter except for - // a possible swift_error parameter. case ParameterABI::SwiftContext: checkForSwiftCC(paramIndex); - if (!(paramIndex == numParams - 1 || - (paramIndex == numParams - 2 && - EPI.ExtParameterInfos[numParams - 1].getABI() - == ParameterABI::SwiftErrorResult))) { - S.Diag(getParamLoc(paramIndex), - diag::err_swift_context_not_before_swift_error_result); - } continue; - // swift_error parameters must be the last parameter. + // swift_error parameters must be preceded by a swift_context parameter. case ParameterABI::SwiftErrorResult: checkForSwiftCC(paramIndex); - if (paramIndex != numParams - 1) { - S.Diag(getParamLoc(paramIndex), - diag::err_swift_error_result_not_last); - } else if (paramIndex == 0 || - EPI.ExtParameterInfos[paramIndex - 1].getABI() - != ParameterABI::SwiftContext) { + if (paramIndex == 0 || + EPI.ExtParameterInfos[paramIndex - 1].getABI() != + ParameterABI::SwiftContext) { S.Diag(getParamLoc(paramIndex), diag::err_swift_error_result_not_after_swift_context); } diff --git a/clang/test/Sema/attr-swiftcall.c b/clang/test/Sema/attr-swiftcall.c index 3458167cf2e..1720612290f 100644 --- a/clang/test/Sema/attr-swiftcall.c +++ b/clang/test/Sema/attr-swiftcall.c @@ -18,13 +18,13 @@ void indirect_result_single(INDIRECT_RESULT void *out) SWIFTCALL; void indirect_result_multiple(INDIRECT_RESULT void *out1, INDIRECT_RESULT void *out2) SWIFTCALL; 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}} -void error_result_bad_position(ERROR_RESULT void **error, int last) SWIFTCALL; // expected-error {{'swift_error_result' parameter must be last parameter of function}} void error_result_bad_position2(int first, ERROR_RESULT void **error) SWIFTCALL; // expected-error {{'swift_error_result' parameter must follow 'swift_context' parameter}} 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'}} 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 *'}} void error_result_okay(int a, int b, CONTEXT void *context, ERROR_RESULT void **error) SWIFTCALL; +void error_result_okay2(CONTEXT void *context, ERROR_RESULT void **error, void *selfType, char **selfWitnessTable) SWIFTCALL; void context_nonswift(CONTEXT void *context); // expected-error {{'swift_context' parameter can only be used with swiftcall calling convention}} -void context_bad_position(CONTEXT void *context, int x) SWIFTCALL; // expected-error {{'swift_context' parameter can only be followed by 'swift_error_result' parameter}} void context_bad_type(CONTEXT int context) SWIFTCALL; // expected-error {{'swift_context' parameter must have pointer type; type here is 'int'}} void context_okay(CONTEXT void *context) SWIFTCALL; +void context_okay2(CONTEXT void *context, void *selfType, char **selfWitnessTable) SWIFTCALL; diff --git a/clang/test/SemaCXX/attr-swiftcall.cpp b/clang/test/SemaCXX/attr-swiftcall.cpp index fd17aae1852..eb9538e3104 100644 --- a/clang/test/SemaCXX/attr-swiftcall.cpp +++ b/clang/test/SemaCXX/attr-swiftcall.cpp @@ -17,16 +17,16 @@ void indirect_result_single(INDIRECT_RESULT void *out) SWIFTCALL; void indirect_result_multiple(INDIRECT_RESULT void *out1, INDIRECT_RESULT void *out2) SWIFTCALL; 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}} -void error_result_bad_position(ERROR_RESULT void **error, int last) SWIFTCALL; // expected-error {{'swift_error_result' parameter must be last parameter of function}} void error_result_bad_position2(int first, ERROR_RESULT void **error) SWIFTCALL; // expected-error {{'swift_error_result' parameter must follow 'swift_context' parameter}} 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'}} 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 *'}} void error_result_okay(int a, int b, CONTEXT void *context, ERROR_RESULT void **error) SWIFTCALL; +void error_result_okay(CONTEXT void *context, ERROR_RESULT void **error, void *selfType, char **selfWitnessTable) SWIFTCALL; void context_nonswift(CONTEXT void *context); // expected-error {{'swift_context' parameter can only be used with swiftcall calling convention}} -void context_bad_position(CONTEXT void *context, int x) SWIFTCALL; // expected-error {{'swift_context' parameter can only be followed by 'swift_error_result' parameter}} void context_bad_type(CONTEXT int context) SWIFTCALL; // expected-error {{'swift_context' parameter must have pointer type; type here is 'int'}} void context_okay(CONTEXT void *context) SWIFTCALL; +void context_okay(CONTEXT void *context, void *selfType, char **selfWitnessTable) SWIFTCALL; template <class T> void indirect_result_temp_okay1(INDIRECT_RESULT T *out) SWIFTCALL; template <class T> void indirect_result_temp_okay2(INDIRECT_RESULT T out) SWIFTCALL; // expected-note {{candidate template ignored: substitution failure [with T = int]: 'swift_indirect_result' parameter must have pointer type; type here is 'int'}} |