Skip to content

Commit f96ea94

Browse files
committed
AST: fixed ast for 'a(new (X), 5);'
1 parent c537c98 commit f96ea94

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

lib/tokenlist.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -664,7 +664,7 @@ static void compilePrecedence3(Token *&tok, AST_state& state)
664664
tok = tok->link()->next();
665665
if (Token::Match(tok->link(), ") %type%"))
666666
tok = tok->link()->next();
667-
else if (Token::Match(tok, "( %type%") && Token::Match(tok->link(), ") [();]"))
667+
else if (Token::Match(tok, "( %type%") && Token::Match(tok->link(), ") [();,]"))
668668
tok = tok->next();
669669
else if (Token::Match(tok, "( &| %var%") && Token::simpleMatch(tok->link(), ") ("))
670670
tok = tok->next();
@@ -682,6 +682,8 @@ static void compilePrecedence3(Token *&tok, AST_state& state)
682682
} else if (tok->str() == "[" || tok->str() == "(")
683683
compilePrecedence2(tok, state);
684684
compileUnaryOp(newtok, state, nullptr);
685+
if (Token::simpleMatch(tok, ") ,"))
686+
tok = tok->next();
685687
} else if (state.cpp && Token::Match(tok, "delete %var%|*|&|::|(|[")) {
686688
Token* tok2 = tok;
687689
tok = tok->next();

test/testtokenize.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8388,6 +8388,7 @@ class TestTokenizer : public TestFixture {
83888388
ASSERT_EQUALS("aFoo(new=", testAst("a = new Foo<bar>();"));
83898389
ASSERT_EQUALS("X12,3,(new", testAst("new (a,b,c) X(1,2,3);"));
83908390
ASSERT_EQUALS("aXnew(", testAst("a (new (X));"));
8391+
ASSERT_EQUALS("aXnew5,(", testAst("a (new (X), 5);"));
83918392
ASSERT_EQUALS("adelete", testAst("delete a;"));
83928393
ASSERT_EQUALS("adelete", testAst("delete (a);"));
83938394
ASSERT_EQUALS("adelete", testAst("delete[] a;"));

0 commit comments

Comments
 (0)