diff options
| author | Sunil Srivastava <sunil_srivastava@playstation.sony.com> | 2019-07-19 21:38:34 +0000 |
|---|---|---|
| committer | Sunil Srivastava <sunil_srivastava@playstation.sony.com> | 2019-07-19 21:38:34 +0000 |
| commit | f4038e75d20257742063826fd0adc2971b3e2367 (patch) | |
| tree | 26a9ed304ebcde3dfb9fe1212d43101d33bdfd13 | |
| parent | 7b5a54e369035a5754be2e836b7b583b3db8c884 (diff) | |
| download | bcm5719-llvm-f4038e75d20257742063826fd0adc2971b3e2367.tar.gz bcm5719-llvm-f4038e75d20257742063826fd0adc2971b3e2367.zip | |
Disallow most calling convention attributes on PS4
PS4 now only allows "cdecl", and its equivalent on PS4, "sysv_abi".
Differential Revision: https://reviews.llvm.org/D64780
llvm-svn: 366617
| -rw-r--r-- | clang/include/clang/Basic/DiagnosticSemaKinds.td | 1 | ||||
| -rw-r--r-- | clang/include/clang/Basic/TargetInfo.h | 1 | ||||
| -rw-r--r-- | clang/lib/Basic/Targets/OSTargets.h | 4 | ||||
| -rw-r--r-- | clang/lib/Sema/SemaDeclAttr.cpp | 5 | ||||
| -rw-r--r-- | clang/test/Sema/no_callconv.cpp | 44 | ||||
| -rw-r--r-- | clang/unittests/Tooling/RecursiveASTVisitorTests/LambdaExpr.cpp | 2 |
6 files changed, 57 insertions, 0 deletions
diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td b/clang/include/clang/Basic/DiagnosticSemaKinds.td index effcbad78b2..04ac4be2d60 100644 --- a/clang/include/clang/Basic/DiagnosticSemaKinds.td +++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td @@ -2966,6 +2966,7 @@ def warn_cconv_unsupported : Warning< "|on builtin function" "}1">, InGroup<IgnoredAttributes>; +def error_cconv_unsupported : Error<warn_cconv_unsupported.Text>; def err_cconv_knr : Error< "function with no prototype cannot use the %0 calling convention">; def warn_cconv_knr : Warning< diff --git a/clang/include/clang/Basic/TargetInfo.h b/clang/include/clang/Basic/TargetInfo.h index 7a8384f5fbc..0ab80a39e2a 100644 --- a/clang/include/clang/Basic/TargetInfo.h +++ b/clang/include/clang/Basic/TargetInfo.h @@ -1268,6 +1268,7 @@ public: CCCR_OK, CCCR_Warning, CCCR_Ignore, + CCCR_Error, }; /// Determines whether a given calling convention is valid for the diff --git a/clang/lib/Basic/Targets/OSTargets.h b/clang/lib/Basic/Targets/OSTargets.h index 8542311ffa4..326fa3dfa4c 100644 --- a/clang/lib/Basic/Targets/OSTargets.h +++ b/clang/lib/Basic/Targets/OSTargets.h @@ -561,6 +561,10 @@ public: break; } } + TargetInfo::CallingConvCheckResult + checkCallingConvention(CallingConv CC) const override { + return (CC == CC_C) ? TargetInfo::CCCR_OK : TargetInfo::CCCR_Error; + } }; // RTEMS Target diff --git a/clang/lib/Sema/SemaDeclAttr.cpp b/clang/lib/Sema/SemaDeclAttr.cpp index ee06f8ae511..5f0b3697d3d 100644 --- a/clang/lib/Sema/SemaDeclAttr.cpp +++ b/clang/lib/Sema/SemaDeclAttr.cpp @@ -4668,6 +4668,11 @@ bool Sema::CheckCallingConvAttr(const ParsedAttr &Attrs, CallingConv &CC, CC = CC_C; break; + case TargetInfo::CCCR_Error: + Diag(Attrs.getLoc(), diag::error_cconv_unsupported) + << Attrs << (int)CallingConventionIgnoredReason::ForThisTarget; + break; + case TargetInfo::CCCR_Warning: { Diag(Attrs.getLoc(), diag::warn_cconv_unsupported) << Attrs << (int)CallingConventionIgnoredReason::ForThisTarget; diff --git a/clang/test/Sema/no_callconv.cpp b/clang/test/Sema/no_callconv.cpp new file mode 100644 index 00000000000..49ce0e88eda --- /dev/null +++ b/clang/test/Sema/no_callconv.cpp @@ -0,0 +1,44 @@ +// RUN: %clang_cc1 %s -triple x86_64-scei-ps4 -DPS4 -fsyntax-only -verify +// RUN: %clang_cc1 %s -triple x86_64-unknown-linux-gnu -fsyntax-only -verify + +#ifdef PS4 + +// PS4 does not support these. +void __vectorcall func_vc() {} // expected-error {{'__vectorcall' calling convention is not supported for this target}} +void __regcall func_rc() {} // expected-error {{'__regcall' calling convention is not supported for this target}} +void __attribute__((vectorcall)) funcA() {} // expected-error {{'vectorcall' calling convention is not supported for this target}} +void __attribute__((regcall)) funcB() {} // expected-error {{'regcall' calling convention is not supported for this target}} +void __attribute__((ms_abi)) funcH() {} // expected-error {{'ms_abi' calling convention is not supported for this target}} +void __attribute__((intel_ocl_bicc)) funcJ() {} // expected-error {{'intel_ocl_bicc' calling convention is not supported for this target}} +void __attribute__((swiftcall)) funcK() {} // expected-error {{'swiftcall' calling convention is not supported for this target}} +void __attribute__((pascal)) funcG() {} // expected-error {{'pascal' calling convention is not supported for this target}} +void __attribute__((preserve_most)) funcL() {} // expected-error {{'preserve_most' calling convention is not supported for this target}} +void __attribute__((preserve_all)) funcM() {} // expected-error {{'preserve_all' calling convention is not supported for this target}} +void __attribute__((stdcall)) funcD() {} // expected-error {{'stdcall' calling convention is not supported for this target}} +void __attribute__((fastcall)) funcE() {} // expected-error {{'fastcall' calling convention is not supported for this target}} +void __attribute__((thiscall)) funcF() {} // expected-error {{'thiscall' calling convention is not supported for this target}} +#else + +void __vectorcall func_vc() {} +void __regcall func_rc() {} +void __attribute__((vectorcall)) funcA() {} +void __attribute__((regcall)) funcB() {} +void __attribute__((ms_abi)) funcH() {} +void __attribute__((intel_ocl_bicc)) funcJ() {} +void __attribute__((swiftcall)) funcK() {} +void __attribute__((preserve_most)) funcL() {} +void __attribute__((preserve_all)) funcM() {} + +// Same function with different calling conventions. Error with a note pointing to the last decl. +void __attribute__((preserve_all)) funcR(); // expected-note {{previous declaration is here}} +void __attribute__((preserve_most)) funcR(); // expected-error {{function declared 'preserve_most' here was previously declared 'preserve_all'}} + +void __attribute__((pascal)) funcG() {} // expected-warning {{'pascal' calling convention is not supported for this target}} + +void __attribute__((stdcall)) funcD() {} // expected-warning {{'stdcall' calling convention is not supported for this target}} +void __attribute__((fastcall)) funcE() {} // expected-warning {{'fastcall' calling convention is not supported for this target}} +void __attribute__((thiscall)) funcF() {} // expected-warning {{'thiscall' calling convention is not supported for this target}} +#endif + +void __attribute__((sysv_abi)) funcI() {} +void __attribute__((cdecl)) funcC() {} diff --git a/clang/unittests/Tooling/RecursiveASTVisitorTests/LambdaExpr.cpp b/clang/unittests/Tooling/RecursiveASTVisitorTests/LambdaExpr.cpp index 560cdf95c0e..f2006fcfc96 100644 --- a/clang/unittests/Tooling/RecursiveASTVisitorTests/LambdaExpr.cpp +++ b/clang/unittests/Tooling/RecursiveASTVisitorTests/LambdaExpr.cpp @@ -86,6 +86,8 @@ TEST(RecursiveASTVisitor, VisitsLambdaExprAndImplicitClass) { } TEST(RecursiveASTVisitor, VisitsAttributedLambdaExpr) { + if (llvm::Triple(llvm::sys::getDefaultTargetTriple()).isPS4()) + return; // PS4 does not support fastcall. LambdaExprVisitor Visitor; Visitor.ExpectMatch("", 1, 12); EXPECT_TRUE(Visitor.runOver( |

