diff options
Diffstat (limited to 'lib/Sema/SemaChecking.cpp')
-rw-r--r-- | lib/Sema/SemaChecking.cpp | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/lib/Sema/SemaChecking.cpp b/lib/Sema/SemaChecking.cpp index d355ba4e99..3e46300b60 100644 --- a/lib/Sema/SemaChecking.cpp +++ b/lib/Sema/SemaChecking.cpp @@ -604,9 +604,16 @@ Sema::CheckPrintfArguments(const CallExpr *TheCall, bool HasVAListArg, if (isa<ParmVarDecl>(DR->getDecl())) return; - Diag(TheCall->getArg(format_idx)->getLocStart(), - diag::warn_printf_not_string_constant) - << OrigFormatExpr->getSourceRange(); + // If there are no arguments specified, warn with -Wformat-security, otherwise + // warn only with -Wformat-nonliteral. + if (TheCall->getNumArgs() == format_idx+1) + Diag(TheCall->getArg(format_idx)->getLocStart(), + diag::warn_printf_nonliteral_noargs) + << OrigFormatExpr->getSourceRange(); + else + Diag(TheCall->getArg(format_idx)->getLocStart(), + diag::warn_printf_nonliteral) + << OrigFormatExpr->getSourceRange(); } void Sema::CheckPrintfString(const StringLiteral *FExpr, |