When calling a function without a prototype for which we have a
definition, warn if there are too many/too few function call
arguments.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@68318 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp
index 1540f0a..b3c8be4 100644
--- a/lib/Sema/SemaExpr.cpp
+++ b/lib/Sema/SemaExpr.cpp
@@ -2368,6 +2368,15 @@
} else {
assert(isa<FunctionNoProtoType>(FuncT) && "Unknown FunctionType!");
+ if (FDecl) {
+ // Check if we have too few/too many template arguments, based
+ // on our knowledge of the function definition.
+ const FunctionDecl *Def = 0;
+ if (FDecl->getBody(Def) && NumArgs != Def->param_size())
+ Diag(RParenLoc, diag::warn_call_wrong_number_of_arguments)
+ << (NumArgs > Def->param_size()) << FDecl << Fn->getSourceRange();
+ }
+
// Promote the arguments (C99 6.5.2.2p6).
for (unsigned i = 0; i != NumArgs; i++) {
Expr *Arg = Args[i];