Fix #11606 internalAstError with empty initializer list (#4875)

This commit is contained in:
chrchr-github 2023-03-09 20:01:06 +01:00 committed by GitHub
parent 2d5cabed4b
commit 6e1cc11eff
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 5 deletions

View File

@ -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, "&|&& )"))

View File

@ -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;"));