From b5faf3a0cc0bbf82ab786ab3d4668b413949876f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Fri, 10 Oct 2014 10:37:54 +0200 Subject: [PATCH] AST: improved handling of new --- lib/tokenlist.cpp | 2 +- test/testtokenize.cpp | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/tokenlist.cpp b/lib/tokenlist.cpp index 6df2070d5..16f637dd2 100644 --- a/lib/tokenlist.cpp +++ b/lib/tokenlist.cpp @@ -667,7 +667,7 @@ static void compilePrecedence3(Token *&tok, AST_state& state) tok = tok->link(); tok = tok->next(); } - if (tok->str() == "[") + if (tok->str() == "[" || tok->str() == "(") compilePrecedence2(tok, state); compileUnaryOp(tok2, state, nullptr); } else if (state.cpp && Token::Match(tok, "delete %var%|*|&|::|(|[")) { diff --git a/test/testtokenize.cpp b/test/testtokenize.cpp index a7caa72a7..2e162ba4e 100644 --- a/test/testtokenize.cpp +++ b/test/testtokenize.cpp @@ -8370,9 +8370,10 @@ private: void astnewdelete() const { ASSERT_EQUALS("aintnew=", testAst("a = new int;")); ASSERT_EQUALS("aint4[new=", testAst("a = new int[4];")); - ASSERT_EQUALS("aFoonew=", testAst("a = new Foo(bar);")); - ASSERT_EQUALS("aFoonew=", testAst("a = new Foo();")); - ASSERT_EQUALS("Xnew", testAst("new (a,b,c) X(1,2,3);")); + ASSERT_EQUALS("aFoobar(new=", testAst("a = new Foo(bar);")); + ASSERT_EQUALS("aFoobar(new=", testAst("a = new Foo(bar);")); + ASSERT_EQUALS("aFoo(new=", testAst("a = new Foo();")); + ASSERT_EQUALS("X12,3,(new", testAst("new (a,b,c) X(1,2,3);")); ASSERT_EQUALS("adelete", testAst("delete a;")); ASSERT_EQUALS("adelete", testAst("delete (a);")); ASSERT_EQUALS("adelete", testAst("delete[] a;"));