diff --git a/lib/tokenlist.cpp b/lib/tokenlist.cpp index d691d0e62..3dd793ec9 100644 --- a/lib/tokenlist.cpp +++ b/lib/tokenlist.cpp @@ -391,11 +391,10 @@ static bool iscast(const Token *tok) if (!Token::Match(tok, "( ::| %name%")) return false; - const Token *prevTok = tok->previous(); - if (prevTok && prevTok->isName() && prevTok->str() != "return") + if (tok->previous() && tok->previous()->isName() && tok->previous()->str() != "return") return false; - if (Token::simpleMatch(prevTok, ">") && prevTok->link()) + if (Token::simpleMatch(tok->previous(), ">") && tok->previous()->link()) return false; if (Token::Match(tok, "( (| typeof (") && Token::Match(tok->link(), ") %num%")) @@ -407,7 +406,7 @@ static bool iscast(const Token *tok) if (Token::Match(tok->link(), ") %cop%") && !Token::Match(tok->link(), ") [&*+-~]")) return false; - if (Token::Match(prevTok, "= ( %name% ) {") && tok->next()->varId() == 0) + if (Token::Match(tok->previous(), "= ( %name% ) {") && tok->next()->varId() == 0) return true; bool type = false;