From c34616a6badc616a30b12be9ec0fa0d1ad5c47f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Sat, 26 Apr 2014 13:16:34 +0200 Subject: [PATCH] AST: Fixed handling of 'a = b.c[++(d.e)];' --- lib/tokenlist.cpp | 4 ++-- test/testtokenize.cpp | 5 ++++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/tokenlist.cpp b/lib/tokenlist.cpp index f100b9a4f..5ab9e55fd 100644 --- a/lib/tokenlist.cpp +++ b/lib/tokenlist.cpp @@ -499,9 +499,9 @@ static void compileTerm(Token *& tok, std::stack &op, unsigned int depth } } else if (Token::Match(tok, "++|--")) { bool pre = false; - if (tok->next() && tok->next()->isName()) + if (Token::Match(tok->next(), "%var%|(")) pre = true; - else if (!op.empty() && !op.top()->isOp()) + else if (!op.empty() && !Token::Match(tok->previous(), "(|[") && !op.top()->isOp()) pre = false; else pre = true; diff --git a/test/testtokenize.cpp b/test/testtokenize.cpp index ffa74ecae..589685c6a 100644 --- a/test/testtokenize.cpp +++ b/test/testtokenize.cpp @@ -10332,6 +10332,9 @@ private: // problems with: if (x[y]==z) ASSERT_EQUALS("ifa(0[1==(", testAst("if(a()[0]==1){}")); ASSERT_EQUALS("ifbuff0[&(*1==(", testAst("if (*((DWORD*)&buff[0])==1){}")); + ASSERT_EQUALS("ifp*0[1==(", testAst("if((*p)[0]==1)")); + + // problems with: x=expr ASSERT_EQUALS("=\n" "|-x\n" "`-(\n" @@ -10341,7 +10344,7 @@ private: " | `-i\n" " `-f\n", testAst("x = ((a[i]).f)();", true)); - ASSERT_EQUALS("ifp*0[1==(", testAst("if((*p)[0]==1)")); + ASSERT_EQUALS("abcde.++[.=", testAst("a = b.c[++(d.e)];")); // casts ASSERT_EQUALS("a1(2(+=",testAst("a=(t)1+(t)2;"));