Fixed #2912 (false positive: (portability) Assigning an integer (int/long/etc) to a pointer is not portable)

This commit is contained in:
Daniel Marjamäki 2011-07-16 17:08:03 +02:00
parent c55b0ff651
commit 35178cc161
2 changed files with 8 additions and 1 deletions

View File

@ -41,7 +41,7 @@ static bool isaddr(const Variable *var)
/** Is given variable an integer variable */
static bool isint(const Variable *var)
{
return (var && Token::Match(var->nameToken()->previous(), "int|long|DWORD"));
return (var && Token::Match(var->nameToken()->previous(), "int|long|DWORD %var% !!["));
}
void Check64BitPortability::pointerassignment()

View File

@ -86,6 +86,13 @@ private:
"}\n");
ASSERT_EQUALS("[test.cpp:3]: (portability) Assigning an address value to the integer (int/long/etc) type is not portable\n", errout.str());
check("int foo(int p[])\n"
"{\n"
" int *a = p;\n"
" return a;\n"
"}\n");
ASSERT_EQUALS("", errout.str());
check("void foo(int x)\n"
"{\n"
" int *p = x;\n"