aboutsummaryrefslogtreecommitdiff
path: root/Sema/SemaChecking.cpp
diff options
context:
space:
mode:
authorAnders Carlsson <andersca@mac.com>2008-02-11 04:20:54 +0000
committerAnders Carlsson <andersca@mac.com>2008-02-11 04:20:54 +0000
commit88cf226caee50956ef47edd4d44cf7b80703a26c (patch)
tree5ff669f88771ab66453a236a1620fa36dd7349d2 /Sema/SemaChecking.cpp
parent54174e8439d22c87639195410619ec7128e293b4 (diff)
Get rid of bogus warnings when the second argument in va_start is either an implicit cast expr or a paren expr.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@46950 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'Sema/SemaChecking.cpp')
-rw-r--r--Sema/SemaChecking.cpp16
1 files changed, 13 insertions, 3 deletions
diff --git a/Sema/SemaChecking.cpp b/Sema/SemaChecking.cpp
index 470211d9ab..76363c9dc0 100644
--- a/Sema/SemaChecking.cpp
+++ b/Sema/SemaChecking.cpp
@@ -149,11 +149,21 @@ bool Sema::SemaBuiltinVAStart(CallExpr *TheCall) {
// Verify that the second argument to the builtin is the last argument of the
// current function or method.
bool SecondArgIsLastNamedArgument = false;
- if (DeclRefExpr *DR = dyn_cast<DeclRefExpr>(TheCall->getArg(1))) {
- if (ParmVarDecl *PV = dyn_cast<ParmVarDecl>(DR->getDecl())) {
+ const Expr *Arg = TheCall->getArg(1);
+ while (1) {
+ if (const ParenExpr *PE = dyn_cast<ParenExpr>(Arg))
+ Arg = PE->getSubExpr();
+ else if (const ImplicitCastExpr *CE = dyn_cast<ImplicitCastExpr>(Arg))
+ Arg = CE->getSubExpr();
+ else
+ break;
+ }
+
+ if (const DeclRefExpr *DR = dyn_cast<DeclRefExpr>(Arg)) {
+ if (const ParmVarDecl *PV = dyn_cast<ParmVarDecl>(DR->getDecl())) {
// FIXME: This isn't correct for methods (results in bogus warning).
// Get the last formal in the current function.
- ParmVarDecl *LastArg;
+ const ParmVarDecl *LastArg;
if (CurFunctionDecl)
LastArg = *(CurFunctionDecl->param_end()-1);
else