Skip to content

Commit 489fc6c

Browse files
committed
AST: more fixes of new statements in clang test suite. some of it is not handled very well.
1 parent 4783a67 commit 489fc6c

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

lib/tokenlist.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -660,12 +660,14 @@ static void compilePrecedence3(Token *&tok, AST_state& state)
660660
Token* newtok = tok;
661661
tok = tok->next();
662662
if (tok->str() == "(") {
663-
if (Token::Match(tok, "( %var% ) ( %type%") && Token::simpleMatch(tok->link()->linkAt(1), ") ("))
663+
if (Token::Match(tok, "( &| %var%") && Token::Match(tok->link(), ") ( %type%") && Token::simpleMatch(tok->link()->linkAt(1), ") ("))
664664
tok = tok->link()->next();
665665
if (Token::Match(tok->link(), ") %type%"))
666666
tok = tok->link()->next();
667667
else if (Token::Match(tok, "( %type%") && Token::Match(tok->link(), ") [(;]"))
668668
tok = tok->next();
669+
else if (Token::Match(tok, "( &| %var%") && Token::simpleMatch(tok->link(), ") ("))
670+
tok = tok->next();
669671
}
670672
state.op.push(tok);
671673
while (Token::Match(tok, "%var%|*|&|<")) {

test/testtokenize.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8391,6 +8391,9 @@ class TestTokenizer : public TestFixture {
83918391
ASSERT_EQUALS("intnew", testAst("new (int S::*[3][4][5]) ();"));
83928392
ASSERT_EQUALS("pSnew=", testAst("p=new (x)(S)(1,2);"));
83938393
ASSERT_EQUALS("inti[new(", testAst("(void)new (int[i]);"));
8394+
ASSERT_EQUALS("intp* pnew malloc4(", testAst("int*p; new (p) (malloc(4));"));
8395+
ASSERT_EQUALS("intnew", testAst("new (&w.x)(int*)(0);"));
8396+
ASSERT_EQUALS("&new", testAst("new (&w.x)(0);")); // <- the "(int*)" has been simplified
83948397
}
83958398

83968399
void astpar() const { // parentheses

0 commit comments

Comments
 (0)