AST: fixed hang for 'new (int S::*[3][4][5])()' (clang test suite)

This commit is contained in:
Daniel Marjamäki 2014-10-11 08:32:49 +02:00
parent 748e3a4ba3
commit e6708c1ae2
2 changed files with 5 additions and 2 deletions

View File

@ -657,10 +657,12 @@ static void compilePrecedence3(Token *&tok, AST_state& state)
compilePrecedence3(tok, state);
compileUnaryOp(tok2, state, nullptr);
} else if (state.cpp && Token::Match(tok, "new %var%|::|(")) {
Token* tok2 = tok;
Token* newtok = tok;
tok = tok->next();
if (tok->str() == "(" && Token::Match(tok->link(), ") %type%"))
tok = tok->link()->next();
else if (Token::Match(tok, "( %type%") && Token::simpleMatch(tok->link(), ") ( )"))
tok = tok->next();
state.op.push(tok);
while (Token::Match(tok, "%var%|*|&|<")) {
if (tok->link())
@ -673,7 +675,7 @@ static void compilePrecedence3(Token *&tok, AST_state& state)
compileBinOp(tok, state, compilePrecedence2);
} else if (tok->str() == "[" || tok->str() == "(")
compilePrecedence2(tok, state);
compileUnaryOp(tok2, state, nullptr);
compileUnaryOp(newtok, state, nullptr);
} else if (state.cpp && Token::Match(tok, "delete %var%|*|&|::|(|[")) {
Token* tok2 = tok;
tok = tok->next();

View File

@ -8382,6 +8382,7 @@ private:
// clang testsuite..
ASSERT_EQUALS("const0(new", testAst("new const auto (0);"));
ASSERT_EQUALS("auto0.0(new", testAst("new (auto) (0.0);"));
ASSERT_EQUALS("intnew", testAst("new (int S::*[3][4][5]) ();"));
}
void astpar() const { // parentheses