longCast: Only warn when original name is 'long'. avoids some FPs when typedef types are used.

This commit is contained in:
Daniel Marjamäki 2015-05-25 18:06:20 +02:00
parent c0b33d2fef
commit a9db06c641
1 changed files with 2 additions and 2 deletions

View File

@ -315,7 +315,7 @@ void CheckType::checkLongCast()
for (const Token *tok = _tokenizer->tokens(); tok; tok = tok->next()) {
if (!Token::Match(tok, "%var% ="))
continue;
if (!tok->variable() || !tok->variable()->isConst() || tok->variable()->typeStartToken()->str() != "long")
if (!tok->variable() || !tok->variable()->isConst() || tok->variable()->typeStartToken()->originalName() != "long")
continue;
if (Token::Match(tok->next()->astOperand2(), "*|<<") && astIsIntResult(tok->next()->astOperand2()))
longCastAssignError(tok);
@ -331,7 +331,7 @@ void CheckType::checkLongCast()
const Token * def = scope->classDef;
bool islong = false;
while (Token::Match(def, "%type%|::")) {
if (def->str() == "long") {
if (def->originalName() == "long") {
islong = true;
break;
}