Fixed #3150 (Invalid warning when pointer difference is not adjacent)
This commit is contained in:
parent
ee04c1bfb7
commit
cf39ece8da
|
@ -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)
|
||||
{
|
||||
|
|
|
@ -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());
|
||||
}
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue