fix ast for expression that starts with number

This commit is contained in:
Daniel Marjamäki 2020-02-21 21:11:32 +01:00
parent ec8c733afb
commit cf10b1a220
3 changed files with 4 additions and 2 deletions

View File

@ -1386,7 +1386,7 @@ static Token * createAstAtToken(Token *tok, bool cpp)
tok = typetok;
}
if (Token::Match(tok, "return|case") || (cpp && tok->str() == "throw") || !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%|++|--|( !!{") || Token::Match(tok->previous(), "[;{}] %num%")) {
if (cpp && (Token::Match(tok->tokAt(-2), "[;{}] new|delete %name%") || Token::Match(tok->tokAt(-3), "[;{}] :: new|delete %name%")))
tok = tok->previous();

View File

@ -2268,7 +2268,7 @@ private:
"{\n"
" 42,malloc(42);\n"
"}");
ASSERT_EQUALS("[test.cpp:3]: (error) Return value of allocation function 'malloc' is not stored.\n", errout.str());
TODO_ASSERT_EQUALS("[test.cpp:3]: (error) Return value of allocation function 'malloc' is not stored.\n", "", errout.str());
check("void *f()\n"
"{\n"

View File

@ -7517,6 +7517,8 @@ private:
ASSERT_EQUALS("ifx3=y;(", testAst("if (int x=3; y)"));
ASSERT_EQUALS("forx0=x;;(", testAst("for (int x=0; x;);"));
ASSERT_EQUALS("0f1(||", testAst("; 0 || f(1);"));
}
void astexpr2() { // limit for large expressions