AST: don't hang when using auto in new statement

This commit is contained in:
Daniel Marjamäki 2014-10-10 12:47:01 +02:00
parent b5faf3a0cc
commit 66d4614a87
2 changed files with 9 additions and 1 deletions

View File

@ -667,7 +667,11 @@ static void compilePrecedence3(Token *&tok, AST_state& state)
tok = tok->link(); tok = tok->link();
tok = tok->next(); tok = tok->next();
} }
if (tok->str() == "[" || tok->str() == "(") if (Token::Match(tok, "( %type% ) (")) {
state.op.push(tok->next());
tok = tok->tokAt(3);
compileBinOp(tok, state, compilePrecedence2);
} else if (tok->str() == "[" || tok->str() == "(")
compilePrecedence2(tok, state); compilePrecedence2(tok, state);
compileUnaryOp(tok2, state, nullptr); compileUnaryOp(tok2, state, nullptr);
} else if (state.cpp && Token::Match(tok, "delete %var%|*|&|::|(|[")) { } else if (state.cpp && Token::Match(tok, "delete %var%|*|&|::|(|[")) {

View File

@ -8378,6 +8378,10 @@ private:
ASSERT_EQUALS("adelete", testAst("delete (a);")); ASSERT_EQUALS("adelete", testAst("delete (a);"));
ASSERT_EQUALS("adelete", testAst("delete[] a;")); ASSERT_EQUALS("adelete", testAst("delete[] a;"));
ASSERT_EQUALS("ab.3c-(delete", testAst("delete[] a.b(3 - c);")); ASSERT_EQUALS("ab.3c-(delete", testAst("delete[] a.b(3 - c);"));
// clang testsuite..
ASSERT_EQUALS("const0(new", testAst("new const auto (0);"));
ASSERT_EQUALS("auto0.0(new", testAst("new (auto) (0.0);"));
} }
void astpar() const { // parentheses void astpar() const { // parentheses