Fixed #3150 (Invalid warning when pointer difference is not adjacent)

This commit is contained in:
Daniel Marjamäki 2011-10-12 19:01:44 +02:00
parent ee04c1bfb7
commit cf39ece8da
2 changed files with 13 additions and 0 deletions

View File

@ -62,10 +62,17 @@ void Check64BitPortability::pointerassignment()
assignmentIntegerToAddressError(tok->next());
else if (isint(var1) && isaddr(var2) && !tok->tokAt(3)->isPointerCompare())
{
// assigning address => warning
// some trivial addition => warning
if (Token::Match(tok->tokAt(4), "+ %any% !!;"))
continue;
assignmentAddressToIntegerError(tok->next());
}
}
}
}
void Check64BitPortability::assignmentAddressToIntegerError(const Token *tok)
{

View File

@ -140,6 +140,12 @@ private:
" int *a = x * x;\n"
"}\n");
TODO_ASSERT_EQUALS("error", "", errout.str());
check("void foo(int *start, int *end) {\n"
" int len;\n"
" int len = end + 10 - start;\n"
"}\n");
ASSERT_EQUALS("", errout.str());
}
};