From 35178cc161925f133121cd818717a672b4a460bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Sat, 16 Jul 2011 17:08:03 +0200 Subject: [PATCH] Fixed #2912 (false positive: (portability) Assigning an integer (int/long/etc) to a pointer is not portable) --- lib/check64bit.cpp | 2 +- test/test64bit.cpp | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/check64bit.cpp b/lib/check64bit.cpp index 3eb6d65ef..320cea698 100644 --- a/lib/check64bit.cpp +++ b/lib/check64bit.cpp @@ -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() diff --git a/test/test64bit.cpp b/test/test64bit.cpp index 0699aaa5b..6974fb068 100644 --- a/test/test64bit.cpp +++ b/test/test64bit.cpp @@ -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"