aboutsummaryrefslogtreecommitdiff
path: root/lib/Sema/SemaChecking.cpp
diff options
context:
space:
mode:
authorChandler Carruth <chandlerc@gmail.com>2010-11-16 08:49:43 +0000
committerChandler Carruth <chandlerc@gmail.com>2010-11-16 08:49:43 +0000
commit9263a3060087eb7b5954ec4ee1ff2c22227b422e (patch)
tree3899802017747e6ef9fcefcb326b505607145e60 /lib/Sema/SemaChecking.cpp
parent07d7e7a6b10f798459f350b792713db2fb3e9365 (diff)
Fix PR8625 and correctly interpret member-calls to static members when
producing warnings. This feels really fragile, and I've not audited all other argument index-based warnings. I suspect we'll grow this bug on another warning eventually. It might be nice to adjust the argument indices when building up the attribute AST node, as we already have to remember about the 'this' argument within that code to produce correct errors. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@119340 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaChecking.cpp')
-rw-r--r--lib/Sema/SemaChecking.cpp16
1 files changed, 10 insertions, 6 deletions
diff --git a/lib/Sema/SemaChecking.cpp b/lib/Sema/SemaChecking.cpp
index 83d7c0760e..bce28c2c91 100644
--- a/lib/Sema/SemaChecking.cpp
+++ b/lib/Sema/SemaChecking.cpp
@@ -1090,12 +1090,16 @@ Sema::CheckPrintfScanfArguments(const CallExpr *TheCall, bool HasVAListArg,
// of member functions is counted. However, it doesn't appear in our own
// lists, so decrement format_idx in that case.
if (isa<CXXMemberCallExpr>(TheCall)) {
- // Catch a format attribute mistakenly referring to the object argument.
- if (format_idx == 0)
- return;
- --format_idx;
- if(firstDataArg != 0)
- --firstDataArg;
+ const CXXMethodDecl *method_decl =
+ dyn_cast<CXXMethodDecl>(TheCall->getCalleeDecl());
+ if (method_decl && method_decl->isInstance()) {
+ // Catch a format attribute mistakenly referring to the object argument.
+ if (format_idx == 0)
+ return;
+ --format_idx;
+ if(firstDataArg != 0)
+ --firstDataArg;
+ }
}
// CHECK: printf/scanf-like function is called with no format string.