Fixed #8418 (AST: wrong ast for throw expression)
This commit is contained in:
parent
7ba9ab7e4c
commit
380ecc408f
|
@ -550,7 +550,7 @@ static void compileTerm(Token *&tok, AST_state& state)
|
||||||
tok = tok->next();
|
tok = tok->next();
|
||||||
} while (Token::Match(tok, "%name%|%str%"));
|
} while (Token::Match(tok, "%name%|%str%"));
|
||||||
} else if (tok->isName()) {
|
} else if (tok->isName()) {
|
||||||
if (Token::Match(tok, "return|case")) {
|
if (Token::Match(tok, "return|case") || (state.cpp && tok->str() == "throw")) {
|
||||||
if (tok->str() == "case")
|
if (tok->str() == "case")
|
||||||
state.inCase = true;
|
state.inCase = true;
|
||||||
compileUnaryOp(tok, state, compileExpression);
|
compileUnaryOp(tok, state, compileExpression);
|
||||||
|
@ -1137,7 +1137,7 @@ static Token * createAstAtToken(Token *tok, bool cpp)
|
||||||
if (Token::Match(tok, "%type% <") && !Token::Match(tok->linkAt(1), "> [({]"))
|
if (Token::Match(tok, "%type% <") && !Token::Match(tok->linkAt(1), "> [({]"))
|
||||||
return tok->linkAt(1);
|
return tok->linkAt(1);
|
||||||
|
|
||||||
if (Token::Match(tok, "return|case") || !tok->previous() || Token::Match(tok, "%name% %op%|(|[|.|::|<|?|;") || Token::Match(tok->previous(), "[;{}] %cop%|++|--|( !!{")) {
|
if (Token::Match(tok, "return|case") || (cpp && tok->str() == "throw") || !tok->previous() || Token::Match(tok, "%name% %op%|(|[|.|::|<|?|;") || Token::Match(tok->previous(), "[;{}] %cop%|++|--|( !!{")) {
|
||||||
if (cpp && (Token::Match(tok->tokAt(-2), "[;{}] new|delete %name%") || Token::Match(tok->tokAt(-3), "[;{}] :: new|delete %name%")))
|
if (cpp && (Token::Match(tok->tokAt(-2), "[;{}] new|delete %name%") || Token::Match(tok->tokAt(-3), "[;{}] :: new|delete %name%")))
|
||||||
tok = tok->previous();
|
tok = tok->previous();
|
||||||
|
|
||||||
|
|
|
@ -8363,6 +8363,8 @@ private:
|
||||||
ASSERT_EQUALS("ab.++", testAst("a.b++;"));
|
ASSERT_EQUALS("ab.++", testAst("a.b++;"));
|
||||||
ASSERT_EQUALS("ab::++", testAst("a::b++;"));
|
ASSERT_EQUALS("ab::++", testAst("a::b++;"));
|
||||||
ASSERT_EQUALS("c5[--*", testAst("*c[5]--;"));
|
ASSERT_EQUALS("c5[--*", testAst("*c[5]--;"));
|
||||||
|
ASSERT_EQUALS("xreturn", testAst("return x;"));
|
||||||
|
ASSERT_EQUALS("x(throw", testAst(";throw x();"));
|
||||||
ASSERT_EQUALS("a*bc:?return", testAst("return *a ? b : c;"));
|
ASSERT_EQUALS("a*bc:?return", testAst("return *a ? b : c;"));
|
||||||
|
|
||||||
// Unary :: operator
|
// Unary :: operator
|
||||||
|
|
Loading…
Reference in New Issue