Skip to content

Commit

Permalink
syntaxError
Browse files Browse the repository at this point in the history
  • Loading branch information
chrchr-github committed Apr 5, 2024
1 parent 992494a commit 21e6723
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/tokenize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5419,8 +5419,8 @@ void Tokenizer::markCppCasts()
if (isC())
return;
for (Token* tok = list.front(); tok; tok = tok->next()) {
if (Token::Match(tok, "const_cast|dynamic_cast|reinterpret_cast|static_cast <")) {
if (!Token::simpleMatch(tok->linkAt(1), "> ("))
if (Token::Match(tok, "const_cast|dynamic_cast|reinterpret_cast|static_cast")) {
if (!Token::simpleMatch(tok->next(), "<") || !Token::simpleMatch(tok->linkAt(1), "> ("))
syntaxError(tok);
tok = tok->linkAt(1)->next();
tok->isCast(true);
Expand Down
1 change: 1 addition & 0 deletions test/testgarbage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1745,6 +1745,7 @@ class TestGarbage : public TestFixture {
}
void garbageCode224() {
ASSERT_THROW(checkCode("void f(){ auto* b = dynamic_cast<const }"), InternalError); // don't crash
ASSERT_THROW(checkCode("void f(){ auto* b = dynamic_cast x; }"), InternalError);
}
void garbageCode225() {
ASSERT_THROW(checkCode("int n() { c * s0, 0 s0 = c(sizeof = ) }"), InternalError);
Expand Down

0 comments on commit 21e6723

Please sign in to comment.