summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaDecl.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'clang/lib/Sema/SemaDecl.cpp')
-rw-r--r--clang/lib/Sema/SemaDecl.cpp15
1 files changed, 15 insertions, 0 deletions
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index 984a14ad50d..1650a11222c 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -11878,6 +11878,21 @@ Decl *Sema::ActOnFinishFunctionBody(Decl *dcl, Stmt *Body,
<< FixItHint::CreateInsertion(FTL.getRParenLoc(), "void");
}
}
+
+ // GNU warning -Wstrict-prototypes
+ // Warn if K&R function is defined without a previous declaration.
+ // This warning is issued only if the definition itself does not provide
+ // a prototype. Only K&R definitions do not provide a prototype.
+ // An empty list in a function declarator that is part of a definition
+ // of that function specifies that the function has no parameters
+ // (C99 6.7.5.3p14)
+ if (!FD->hasWrittenPrototype() && FD->getNumParams() > 0 &&
+ !LangOpts.CPlusPlus) {
+ TypeSourceInfo *TI = FD->getTypeSourceInfo();
+ TypeLoc TL = TI->getTypeLoc();
+ FunctionTypeLoc FTL = TL.castAs<FunctionTypeLoc>();
+ Diag(FTL.getLParenLoc(), diag::warn_strict_prototypes) << 1;
+ }
}
if (auto *MD = dyn_cast<CXXMethodDecl>(FD)) {
OpenPOWER on IntegriCloud