diff options
Diffstat (limited to 'clang/lib/Sema')
| -rw-r--r-- | clang/lib/Sema/SemaDecl.cpp | 9 | ||||
| -rw-r--r-- | clang/lib/Sema/SemaDeclAttr.cpp | 3 | ||||
| -rw-r--r-- | clang/lib/Sema/SemaType.cpp | 22 |
3 files changed, 21 insertions, 13 deletions
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp index 2f8295aa977..4aa9dc25ac9 100644 --- a/clang/lib/Sema/SemaDecl.cpp +++ b/clang/lib/Sema/SemaDecl.cpp @@ -3136,6 +3136,15 @@ bool Sema::MergeFunctionDecl(FunctionDecl *New, NamedDecl *&OldD, // there but not here. NewTypeInfo = NewTypeInfo.withCallingConv(OldTypeInfo.getCC()); RequiresAdjustment = true; + } else if (New->getBuiltinID()) { + // Calling Conventions on a Builtin aren't really useful and setting a + // default calling convention and cdecl'ing some builtin redeclarations is + // common, so warn and ignore the calling convention on the redeclaration. + Diag(New->getLocation(), diag::warn_cconv_ignored) + << FunctionType::getNameForCallConv(NewTypeInfo.getCC()) + << (int)CallingConventionIgnoredReason::BuiltinFunction; + NewTypeInfo = NewTypeInfo.withCallingConv(OldTypeInfo.getCC()); + RequiresAdjustment = true; } else { // Calling conventions aren't compatible, so complain. bool FirstCCExplicit = getCallingConvAttributedType(First->getType()); diff --git a/clang/lib/Sema/SemaDeclAttr.cpp b/clang/lib/Sema/SemaDeclAttr.cpp index e8a77b3dc28..dcccb4b468a 100644 --- a/clang/lib/Sema/SemaDeclAttr.cpp +++ b/clang/lib/Sema/SemaDeclAttr.cpp @@ -4652,7 +4652,8 @@ bool Sema::CheckCallingConvAttr(const ParsedAttr &Attrs, CallingConv &CC, } if (A != TargetInfo::CCCR_OK) { if (A == TargetInfo::CCCR_Warning) - Diag(Attrs.getLoc(), diag::warn_cconv_ignored) << Attrs; + Diag(Attrs.getLoc(), diag::warn_cconv_ignored) + << Attrs << (int)CallingConventionIgnoredReason::ForThisTarget; // This convention is not valid for the target. Use the default function or // method calling convention. diff --git a/clang/lib/Sema/SemaType.cpp b/clang/lib/Sema/SemaType.cpp index 7c36abfa5b8..d4a6fc8ff64 100644 --- a/clang/lib/Sema/SemaType.cpp +++ b/clang/lib/Sema/SemaType.cpp @@ -6930,19 +6930,16 @@ static bool handleFunctionTypeAttr(TypeProcessingState &state, ParsedAttr &attr, if (!supportsVariadicCall(CC)) { const FunctionProtoType *FnP = dyn_cast<FunctionProtoType>(fn); if (FnP && FnP->isVariadic()) { - unsigned DiagID = diag::err_cconv_varargs; - // stdcall and fastcall are ignored with a warning for GCC and MS // compatibility. - bool IsInvalid = true; - if (CC == CC_X86StdCall || CC == CC_X86FastCall) { - DiagID = diag::warn_cconv_varargs; - IsInvalid = false; - } + if (CC == CC_X86StdCall || CC == CC_X86FastCall) + return S.Diag(attr.getLoc(), diag::warn_cconv_ignored) + << FunctionType::getNameForCallConv(CC) + << (int)Sema::CallingConventionIgnoredReason::VariadicFunction; - S.Diag(attr.getLoc(), DiagID) << FunctionType::getNameForCallConv(CC); - if (IsInvalid) attr.setInvalid(); - return true; + attr.setInvalid(); + return S.Diag(attr.getLoc(), diag::err_cconv_varargs) + << FunctionType::getNameForCallConv(CC); } } @@ -6997,8 +6994,9 @@ void Sema::adjustMemberFunctionCC(QualType &T, bool IsStatic, bool IsCtorOrDtor, // Issue a warning on ignored calling convention -- except of __stdcall. // Again, this is what MS compiler does. if (CurCC != CC_X86StdCall) - Diag(Loc, diag::warn_cconv_structors) - << FunctionType::getNameForCallConv(CurCC); + Diag(Loc, diag::warn_cconv_ignored) + << FunctionType::getNameForCallConv(CurCC) + << (int)Sema::CallingConventionIgnoredReason::ConstructorDestructor; // Default adjustment. } else { // Only adjust types with the default convention. For example, on Windows |

