diff --git a/lib/tokenlist.cpp b/lib/tokenlist.cpp index 6f12d39e5..ffcacf21f 100644 --- a/lib/tokenlist.cpp +++ b/lib/tokenlist.cpp @@ -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, "&|&& )")) diff --git a/test/testtokenize.cpp b/test/testtokenize.cpp index ee255ad16..9dfe3ea3c 100644 --- a/test/testtokenize.cpp +++ b/test/testtokenize.cpp @@ -6387,6 +6387,8 @@ private: 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;"));