diff --git a/lib/checkother.cpp b/lib/checkother.cpp index e1ec50c1e..a9be46436 100644 --- a/lib/checkother.cpp +++ b/lib/checkother.cpp @@ -3217,7 +3217,7 @@ void CheckOther::checkSignOfUnsignedVariable() const Variable *var = tok->tokAt(2)->variable(); if (var && var->typeEndToken()->isUnsigned()) unsignedLessThanZeroError(tok, var->name(), inconclusive); - else if (var && var->isPointer() && !Token::Match(tok->tokAt(3), "[.[]")) + else if (var && var->isPointer() && !Token::Match(tok->tokAt(3), "[.[(]")) pointerLessThanZeroError(tok, inconclusive); } else if (Token::Match(tok, "0 <= %var%") && tok->tokAt(2)->varId() && !Token::Match(tok->tokAt(3), "+|-|*|/") && !Token::Match(tok->previous(), "+|-|<<|>>|~")) { const Variable *var = tok->tokAt(2)->variable(); diff --git a/test/testother.cpp b/test/testother.cpp index e89001c42..310620d29 100644 --- a/test/testother.cpp +++ b/test/testother.cpp @@ -4949,6 +4949,22 @@ private: " bar();\n" "}"); ASSERT_EQUALS("", errout.str()); + + check_signOfUnsignedVariable( + "void foo() {\n" + " int (*t)(void *a, void *b);\n" + " if (t(a, b) < 0)\n" + " bar();\n" + "}"); + ASSERT_EQUALS("", errout.str()); + + check_signOfUnsignedVariable( + "void foo() {\n" + " int (*t)(void *a, void *b);\n" + " if (0 > t(a, b))\n" + " bar();\n" + "}"); + ASSERT_EQUALS("", errout.str()); } void checkForSuspiciousSemicolon1() {