summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaDecl.cpp
diff options
context:
space:
mode:
authorReid Kleckner <reid@kleckner.net>2014-11-03 21:24:50 +0000
committerReid Kleckner <reid@kleckner.net>2014-11-03 21:24:50 +0000
commit1eaa844f3e6e8140375212f6578d449087f0d6f4 (patch)
treef16635230cc5798b1700f87ab7c57e3ba870d1ff /clang/lib/Sema/SemaDecl.cpp
parentf0c7dbd1c8026002afce3e74a72e3707b5b530c9 (diff)
downloadbcm5719-llvm-1eaa844f3e6e8140375212f6578d449087f0d6f4.tar.gz
bcm5719-llvm-1eaa844f3e6e8140375212f6578d449087f0d6f4.zip
Don't diagnose no-prototype callee-cleanup function definitions
We already have a warning on the call sites of code like this: void f() { } void g() { f(1, 2, 3); } t.c:2:21: warning: too many arguments in call to 'f' We can limit ourselves to diagnosing unprototyped forward declarations of f to cut down on noise. llvm-svn: 221184
Diffstat (limited to 'clang/lib/Sema/SemaDecl.cpp')
-rw-r--r--clang/lib/Sema/SemaDecl.cpp30
1 files changed, 15 insertions, 15 deletions
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index fe5981121fe..b9f8f637e21 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -7383,6 +7383,21 @@ Sema::ActOnFunctionDeclarator(Scope *S, Declarator &D, DeclContext *DC,
if (!NewFD->isInvalidDecl() && NewFD->isMSVCRTEntryPoint())
CheckMSVCRTEntryPoint(NewFD);
+ // Diagnose no-prototype function declarations with calling conventions that
+ // don't support variadic calls.
+ const FunctionType *FT = R->castAs<FunctionType>();
+ if (FT->isFunctionNoProtoType() && !D.isFunctionDefinition()) {
+ CallingConv CC = FT->getExtInfo().getCC();
+ if (!supportsVariadicCall(CC)) {
+ // Windows system headers sometimes accidentally use stdcall without
+ // (void) parameters, so we relax this to a warning.
+ int DiagID =
+ CC == CC_X86StdCall ? diag::warn_cconv_knr : diag::err_cconv_knr;
+ Diag(NewFD->getLocation(), DiagID)
+ << FunctionType::getNameForCallConv(CC);
+ }
+ }
+
if (!NewFD->isInvalidDecl())
D.setRedeclaration(CheckFunctionDeclaration(S, NewFD, Previous,
isExplicitSpecialization));
@@ -7948,21 +7963,6 @@ bool Sema::CheckFunctionDeclaration(Scope *S, FunctionDecl *NewFD,
// Semantic checking for this function declaration (in isolation).
- // Diagnose calling conventions that don't support variadic calls.
- QualType NewQType = Context.getCanonicalType(NewFD->getType());
- const FunctionType *NewType = cast<FunctionType>(NewQType);
- if (isa<FunctionNoProtoType>(NewType)) {
- FunctionType::ExtInfo NewTypeInfo = NewType->getExtInfo();
- if (!supportsVariadicCall(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) {
// C++-specific checks.
if (CXXConstructorDecl *Constructor = dyn_cast<CXXConstructorDecl>(NewFD)) {
OpenPOWER on IntegriCloud