Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions lib/tokenlist.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -483,12 +483,13 @@ static bool iscast(const Token *tok, bool cpp)
const Token *tok3 = tok2->linkAt(1);
while (tok3 != tok2 && Token::Match(tok3, "[{}]"))
tok3 = tok3->previous();
return tok3 != tok2 && tok3->str() != ";";
return tok3->str() != ";";
}
return type || tok2->strAt(-1) == "*" || Token::simpleMatch(tok2, ") ~") ||
(Token::Match(tok2, ") %any%") &&
(!tok2->next()->isOp() || Token::Match(tok2->next(), "!|~|++|--")) &&
!Token::Match(tok2->next(), "[[]);,?:.]"));
const bool res = type || tok2->strAt(-1) == "*" || Token::simpleMatch(tok2, ") ~") ||
(Token::Match(tok2, ") %any%") &&
(!tok2->next()->isOp() || Token::Match(tok2->next(), "!|~|++|--")) &&
!Token::Match(tok2->next(), "[[]);,?:.]"));
return res;
}

if (Token::Match(tok2, "&|&& )"))
Expand Down
2 changes: 2 additions & 0 deletions test/testtokenize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6387,6 +6387,8 @@ class TestTokenizer : public TestFixture {

ASSERT_EQUALS("xp(= 12>34:?", testAst("x = ( const char ( * ) [ 1 > 2 ? 3 : 4 ] ) p ;"));

ASSERT_EQUALS("f{(si.,(", testAst("f((struct S){ }, s->i);")); // #11606

// not cast
ASSERT_EQUALS("AB||", testAst("(A)||(B)"));
ASSERT_EQUALS("abc[1&=", testAst("a = (b[c]) & 1;"));
Expand Down