Index: include/clang/Basic/DiagnosticSemaKinds.td =================================================================== --- include/clang/Basic/DiagnosticSemaKinds.td +++ include/clang/Basic/DiagnosticSemaKinds.td @@ -2957,6 +2957,14 @@ def err_cconv_change : Error< "function declared '%0' here was previously declared " "%select{'%2'|without calling convention}1">; +def error_cconv_unsupported : Error< + "%0 calling convention not supported %select{" + // Use CallingConventionIgnoredReason Enum to specify these. + "for this target" + "|on variadic function" + "|on constructor/destructor" + "|on builtin function" + "}1">; def warn_cconv_ignored : Warning< "%0 calling convention ignored %select{" // Use CallingConventionIgnoredReason Enum to specify these. Index: include/clang/Basic/TargetInfo.h =================================================================== --- include/clang/Basic/TargetInfo.h +++ include/clang/Basic/TargetInfo.h @@ -1268,6 +1268,7 @@ CCCR_OK, CCCR_Warning, CCCR_Ignore, + CCCR_Error, }; /// Determines whether a given calling convention is valid for the Index: lib/Basic/Targets/X86.h =================================================================== --- lib/Basic/Targets/X86.h +++ lib/Basic/Targets/X86.h @@ -643,6 +643,8 @@ } CallingConvCheckResult checkCallingConvention(CallingConv CC) const override { + if (getTriple().isPS4()) + return (CC == CC_C) ? CCCR_OK : CCCR_Error; switch (CC) { case CC_C: case CC_Swift: Index: lib/Sema/SemaDeclAttr.cpp =================================================================== --- lib/Sema/SemaDeclAttr.cpp +++ lib/Sema/SemaDeclAttr.cpp @@ -4668,6 +4668,11 @@ 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_ignored) << Attrs << (int)CallingConventionIgnoredReason::ForThisTarget; Index: test/Sema/no_callconv.cpp =================================================================== --- test/Sema/no_callconv.cpp +++ 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 not supported for this target}} +void __regcall func_rc() {} // expected-error {{'__regcall' calling convention not supported for this target}} +void __attribute__((vectorcall)) funcA() {} // expected-error {{'vectorcall' calling convention not supported for this target}} +void __attribute__((regcall)) funcB() {} // expected-error {{'regcall' calling convention not supported for this target}} +void __attribute__((ms_abi)) funcH() {} // expected-error {{'ms_abi' calling convention not supported for this target}} +void __attribute__((intel_ocl_bicc)) funcJ() {} // expected-error {{'intel_ocl_bicc' calling convention not supported for this target}} +void __attribute__((swiftcall)) funcK() {} // expected-error {{'swiftcall' calling convention not supported for this target}} +void __attribute__((pascal)) funcG() {} // expected-error {{'pascal' calling convention not supported for this target}} +void __attribute__((preserve_most)) funcL() {} // expected-error {{'preserve_most' calling convention not supported for this target}} +void __attribute__((preserve_all)) funcM() {} // expected-error {{'preserve_all' calling convention not supported for this target}} +void __attribute__((stdcall)) funcD() {} // expected-error {{'stdcall' calling convention not supported for this target}} +void __attribute__((fastcall)) funcE() {} // expected-error {{'fastcall' calling convention not supported for this target}} +void __attribute__((thiscall)) funcF() {} // expected-error {{'thiscall' calling convention 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 ignored for this target}} + +void __attribute__((stdcall)) funcD() {} // expected-warning {{'stdcall' calling convention ignored for this target}} +void __attribute__((fastcall)) funcE() {} // expected-warning {{'fastcall' calling convention ignored for this target}} +void __attribute__((thiscall)) funcF() {} // expected-warning {{'thiscall' calling convention ignored for this target}} +#endif + +void __attribute__((sysv_abi)) funcI() {} +void __attribute__((cdecl)) funcC() {} Index: unittests/Tooling/RecursiveASTVisitorTests/LambdaExpr.cpp =================================================================== --- unittests/Tooling/RecursiveASTVisitorTests/LambdaExpr.cpp +++ unittests/Tooling/RecursiveASTVisitorTests/LambdaExpr.cpp @@ -86,6 +86,8 @@ } 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(