aboutsummaryrefslogtreecommitdiff
path: root/lib/Sema/SemaChecking.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Sema/SemaChecking.cpp')
-rw-r--r--lib/Sema/SemaChecking.cpp10
1 files changed, 6 insertions, 4 deletions
diff --git a/lib/Sema/SemaChecking.cpp b/lib/Sema/SemaChecking.cpp
index 3e6bd5a2ef..b0d6901953 100644
--- a/lib/Sema/SemaChecking.cpp
+++ b/lib/Sema/SemaChecking.cpp
@@ -143,12 +143,14 @@ Sema::CheckFunctionCall(FunctionDecl *FDecl, CallExpr *TheCall) {
// Printf checking.
if (const FormatAttr *Format = FDecl->getAttr<FormatAttr>()) {
if (Format->getType() == "printf") {
- bool HasVAListArg = false;
- if (const FunctionProtoType *Proto
- = FDecl->getType()->getAsFunctionProtoType())
+ bool HasVAListArg = Format->getFirstArg() == 0;
+ if (!HasVAListArg) {
+ if (const FunctionProtoType *Proto
+ = FDecl->getType()->getAsFunctionProtoType())
HasVAListArg = !Proto->isVariadic();
+ }
CheckPrintfArguments(TheCall, HasVAListArg, Format->getFormatIdx() - 1,
- Format->getFirstArg() - 1);
+ HasVAListArg ? 0 : Format->getFirstArg() - 1);
}
}