Skip to content

Commit 35178cc

Browse files
author
Daniel Marjamäki
committed
Fixed danmar#2912 (false positive: (portability) Assigning an integer (int/long/etc) to a pointer is not portable)
1 parent c55b0ff commit 35178cc

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

lib/check64bit.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ static bool isaddr(const Variable *var)
4141
/** Is given variable an integer variable */
4242
static bool isint(const Variable *var)
4343
{
44-
return (var && Token::Match(var->nameToken()->previous(), "int|long|DWORD"));
44+
return (var && Token::Match(var->nameToken()->previous(), "int|long|DWORD %var% !!["));
4545
}
4646

4747
void Check64BitPortability::pointerassignment()

test/test64bit.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,13 @@ class Test64BitPortability : public TestFixture
8686
"}\n");
8787
ASSERT_EQUALS("[test.cpp:3]: (portability) Assigning an address value to the integer (int/long/etc) type is not portable\n", errout.str());
8888

89+
check("int foo(int p[])\n"
90+
"{\n"
91+
" int *a = p;\n"
92+
" return a;\n"
93+
"}\n");
94+
ASSERT_EQUALS("", errout.str());
95+
8996
check("void foo(int x)\n"
9097
"{\n"
9198
" int *p = x;\n"

0 commit comments

Comments
 (0)