From d091639080d9c355264990720dee0e64aca1bf4b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Sun, 1 Feb 2015 12:58:06 +0100 Subject: [PATCH] Fixed #6482 (False positive multiCondition) --- lib/checkcondition.cpp | 2 +- test/testcondition.cpp | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/checkcondition.cpp b/lib/checkcondition.cpp index fb566e57e..08f31cedb 100644 --- a/lib/checkcondition.cpp +++ b/lib/checkcondition.cpp @@ -286,7 +286,7 @@ static bool isOverlappingCond(const Token * const cond1, const Token * const con const MathLib::bigint value1 = MathLib::toLongNumber(num1->str()); const MathLib::bigint value2 = MathLib::toLongNumber(num2->str()); - return ((value1 & value2) == value2); + return (value2 > 0 && (value1 & value2) == value2); } return false; } diff --git a/test/testcondition.cpp b/test/testcondition.cpp index 402e23879..8c503ef5a 100644 --- a/test/testcondition.cpp +++ b/test/testcondition.cpp @@ -451,6 +451,12 @@ private: " else if (dynamic_cast(widget)){}\n" "}",false); ASSERT_EQUALS("", errout.str()); + + check("void f(int x) {\n" // #6482 + " if (x & 1) {}\n" + " else if (x == 0) {}\n" + "}",false); + ASSERT_EQUALS("", errout.str()); } void invalidMissingSemicolon() {