AST: more fixes of new statements in clang test suite. some of it is not handled very well.

This commit is contained in:
Daniel Marjamäki 2014-10-11 13:20:48 +02:00
parent 4783a67042
commit 489fc6cce7
2 changed files with 6 additions and 1 deletions

View File

@ -660,12 +660,14 @@ static void compilePrecedence3(Token *&tok, AST_state& state)
Token* newtok = tok; Token* newtok = tok;
tok = tok->next(); tok = tok->next();
if (tok->str() == "(") { if (tok->str() == "(") {
if (Token::Match(tok, "( %var% ) ( %type%") && Token::simpleMatch(tok->link()->linkAt(1), ") (")) if (Token::Match(tok, "( &| %var%") && Token::Match(tok->link(), ") ( %type%") && Token::simpleMatch(tok->link()->linkAt(1), ") ("))
tok = tok->link()->next(); tok = tok->link()->next();
if (Token::Match(tok->link(), ") %type%")) if (Token::Match(tok->link(), ") %type%"))
tok = tok->link()->next(); tok = tok->link()->next();
else if (Token::Match(tok, "( %type%") && Token::Match(tok->link(), ") [(;]")) else if (Token::Match(tok, "( %type%") && Token::Match(tok->link(), ") [(;]"))
tok = tok->next(); tok = tok->next();
else if (Token::Match(tok, "( &| %var%") && Token::simpleMatch(tok->link(), ") ("))
tok = tok->next();
} }
state.op.push(tok); state.op.push(tok);
while (Token::Match(tok, "%var%|*|&|<")) { while (Token::Match(tok, "%var%|*|&|<")) {

View File

@ -8391,6 +8391,9 @@ private:
ASSERT_EQUALS("intnew", testAst("new (int S::*[3][4][5]) ();")); ASSERT_EQUALS("intnew", testAst("new (int S::*[3][4][5]) ();"));
ASSERT_EQUALS("pSnew=", testAst("p=new (x)(S)(1,2);")); ASSERT_EQUALS("pSnew=", testAst("p=new (x)(S)(1,2);"));
ASSERT_EQUALS("inti[new(", testAst("(void)new (int[i]);")); ASSERT_EQUALS("inti[new(", testAst("(void)new (int[i]);"));
ASSERT_EQUALS("intp* pnew malloc4(", testAst("int*p; new (p) (malloc(4));"));
ASSERT_EQUALS("intnew", testAst("new (&w.x)(int*)(0);"));
ASSERT_EQUALS("&new", testAst("new (&w.x)(0);")); // <- the "(int*)" has been simplified
} }
void astpar() const { // parentheses void astpar() const { // parentheses