diff options
author | Nico Weber <nicolasweber@gmx.de> | 2014-09-19 23:07:12 +0000 |
---|---|---|
committer | Nico Weber <nicolasweber@gmx.de> | 2014-09-19 23:07:12 +0000 |
commit | d191063c6c507aa24bc1d2346b17966aac4a734b (patch) | |
tree | bb102411c87aecf9f1b29db1917c9219d8cb6192 /clang/lib/Sema/SemaDecl.cpp | |
parent | de0253791cfadd186b904f75c406d4fdcbf58899 (diff) | |
download | bcm5719-llvm-d191063c6c507aa24bc1d2346b17966aac4a734b.tar.gz bcm5719-llvm-d191063c6c507aa24bc1d2346b17966aac4a734b.zip |
Follow-up to r214408: Warn on other callee-cleanup functions without prototype too.
According to lore, we used to verifier-fail on:
void __thiscall f();
int main() { f(1); }
So that's fixed now. System headers use prototype-less __stdcall functions,
so make that a warning that's DefaultError -- then it fires on regular code
but is suppressed in system headers.
Since it's used in system headers, we have codegen tests for this; massage
them slightly so that they still compile.
llvm-svn: 218166
Diffstat (limited to 'clang/lib/Sema/SemaDecl.cpp')
-rw-r--r-- | clang/lib/Sema/SemaDecl.cpp | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp index 0aaa60c90fe..535e33a2b6e 100644 --- a/clang/lib/Sema/SemaDecl.cpp +++ b/clang/lib/Sema/SemaDecl.cpp @@ -7937,15 +7937,19 @@ bool Sema::CheckFunctionDeclaration(Scope *S, FunctionDecl *NewFD, // Semantic checking for this function declaration (in isolation). - // Diagnose the use of X86 fastcall on unprototyped functions. + // Diagnose the use of callee-cleanup calls on unprototyped functions. QualType NewQType = Context.getCanonicalType(NewFD->getType()); const FunctionType *NewType = cast<FunctionType>(NewQType); if (isa<FunctionNoProtoType>(NewType)) { FunctionType::ExtInfo NewTypeInfo = NewType->getExtInfo(); - if (NewTypeInfo.getCC() == CC_X86FastCall) - Diag(NewFD->getLocation(), diag::err_cconv_knr) - << FunctionType::getNameForCallConv(CC_X86FastCall); - // TODO: Also diagnose unprototyped stdcall functions? + if (isCalleeCleanup(NewTypeInfo.getCC())) { + // Windows system headers sometimes accidentally use stdcall without + // (void) parameters, so use a default-error warning in this case :-/ + int DiagID = NewTypeInfo.getCC() == CC_X86StdCall + ? diag::warn_cconv_knr : diag::err_cconv_knr; + Diag(NewFD->getLocation(), DiagID) + << FunctionType::getNameForCallConv(NewTypeInfo.getCC()); + } } if (getLangOpts().CPlusPlus) { |