diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Basic/Targets.cpp | 26 | ||||
-rw-r--r-- | lib/Sema/SemaDeclAttr.cpp | 7 | ||||
-rw-r--r-- | lib/Sema/SemaType.cpp | 6 |
3 files changed, 36 insertions, 3 deletions
diff --git a/lib/Basic/Targets.cpp b/lib/Basic/Targets.cpp index 201913774c..6469c46574 100644 --- a/lib/Basic/Targets.cpp +++ b/lib/Basic/Targets.cpp @@ -1673,6 +1673,19 @@ public: } llvm_unreachable("Unhandled CPU kind"); } + + virtual CallingConvCheckResult checkCallingConvention(CallingConv CC) const { + // We accept all non-ARM calling conventions + return (CC == CC_X86ThisCall || + CC == CC_X86FastCall || + CC == CC_X86StdCall || + CC == CC_C || + CC == CC_X86Pascal) ? CCCR_OK : CCCR_Warning; + } + + virtual CallingConv getDefaultCallingConv() const { + return CC_C; + } }; void X86TargetInfo::getDefaultFeatures(llvm::StringMap<bool> &Features) const { @@ -2708,6 +2721,15 @@ public: if (RegNo == 1) return 1; return -1; } + + virtual CallingConvCheckResult checkCallingConvention(CallingConv CC) const { + return TargetInfo::checkCallingConvention(CC); + } + + virtual CallingConv getDefaultCallingConv() const { + return CC_Default; + } + }; } // end anonymous namespace @@ -3167,6 +3189,10 @@ public: // FIXME: Is this really right? return ""; } + + virtual CallingConvCheckResult checkCallingConvention(CallingConv CC) const { + return (CC == CC_AAPCS || CC == CC_AAPCS_VFP) ? CCCR_OK : CCCR_Warning; + } }; const char * const ARMTargetInfo::GCCRegNames[] = { diff --git a/lib/Sema/SemaDeclAttr.cpp b/lib/Sema/SemaDeclAttr.cpp index b09ec08651..5671a0fd21 100644 --- a/lib/Sema/SemaDeclAttr.cpp +++ b/lib/Sema/SemaDeclAttr.cpp @@ -3638,6 +3638,13 @@ bool Sema::CheckCallingConvAttr(const AttributeList &attr, CallingConv &CC) { default: llvm_unreachable("unexpected attribute kind"); } + const TargetInfo &TI = Context.getTargetInfo(); + TargetInfo::CallingConvCheckResult A = TI.checkCallingConvention(CC); + if (A == TargetInfo::CCCR_Warning) { + Diag(attr.getLoc(), diag::warn_cconv_ignored) << attr.getName(); + CC = TI.getDefaultCallingConv(); + } + return false; } diff --git a/lib/Sema/SemaType.cpp b/lib/Sema/SemaType.cpp index 243ae12d2a..a3af981c37 100644 --- a/lib/Sema/SemaType.cpp +++ b/lib/Sema/SemaType.cpp @@ -3886,14 +3886,14 @@ static bool handleFunctionTypeAttr(TypeProcessingState &state, return true; } + // Delay if the type didn't work out to a function. + if (!unwrapped.isFunctionType()) return false; + // Otherwise, a calling convention. CallingConv CC; if (S.CheckCallingConvAttr(attr, CC)) return true; - // Delay if the type didn't work out to a function. - if (!unwrapped.isFunctionType()) return false; - const FunctionType *fn = unwrapped.get(); CallingConv CCOld = fn->getCallConv(); if (S.Context.getCanonicalCallConv(CC) == |