Skip to content

Commit

Permalink
Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
chrchr-github committed Feb 16, 2024
1 parent 442aeb4 commit 40336c4
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lib/checkother.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -313,10 +313,12 @@ void CheckOther::warningOldStylePointerCast()
tok = scope->bodyStart;
for (; tok && tok != scope->bodyEnd; tok = tok->next()) {
// Old style pointer casting..
if (tok->str() != "(")
continue;
const Token* castTok = tok->next();
while (Token::Match(castTok, "const|volatile|class|struct|union|%type%|::"))
castTok = castTok->next();
if (!Token::simpleMatch(castTok, "*"))
if (castTok == tok->next() || !Token::simpleMatch(castTok, "*"))
continue;
while (Token::Match(castTok, "*|const|&"))
castTok = castTok->next();
Expand All @@ -327,7 +329,7 @@ void CheckOther::warningOldStylePointerCast()
continue;

// skip first "const" in "const Type* const"
while (Token::Match(tok->next(), "const|volatile|class|struct"))
while (Token::Match(tok->next(), "const|volatile|class|struct|union"))
tok = tok->next();
const Token* typeTok = tok->next();
// skip second "const" in "const Type* const"
Expand Down

0 comments on commit 40336c4

Please sign in to comment.