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,7 +62,14 @@ void Check64BitPortability::pointerassignment()
assignmentIntegerToAddressError(tok->next()); assignmentIntegerToAddressError(tok->next());
else if (isint(var1) && isaddr(var2) && !tok->tokAt(3)->isPointerCompare()) 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()); assignmentAddressToIntegerError(tok->next());
}
} }
} }
} }

View File

@ -140,6 +140,12 @@ private:
" int *a = x * x;\n" " int *a = x * x;\n"
"}\n"); "}\n");
TODO_ASSERT_EQUALS("error", "", errout.str()); 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());
} }
}; };