Fixed #2912 (false positive: (portability) Assigning an integer (int/long/etc) to a pointer is not portable)
This commit is contained in:
parent
c55b0ff651
commit
35178cc161
|
@ -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()
|
||||
|
|
|
@ -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"
|
||||
|
|
Loading…
Reference in New Issue