From 302daeb9bd939cf27a4d497cec7d445a6edb655d Mon Sep 17 00:00:00 2001 From: Robert Reif Date: Mon, 12 Sep 2011 20:46:00 -0400 Subject: [PATCH] add test for #3110 (false positve: style) Boolean result is used in bitwise operation. Clarify expression with parentheses) --- test/testother.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/test/testother.cpp b/test/testother.cpp index f9cdc2270..9d3569ca4 100644 --- a/test/testother.cpp +++ b/test/testother.cpp @@ -120,6 +120,7 @@ private: TEST_CASE(clarifyCondition1); // if (a = b() < 0) TEST_CASE(clarifyCondition2); // if (a & b == c) TEST_CASE(clarifyCondition3); // if (! a & b) + TEST_CASE(clarifyCondition4); // ticket #3110 TEST_CASE(bitwiseOnBoolean); // if (bool & bool) TEST_CASE(incorrectStringCompare); @@ -2837,6 +2838,22 @@ private: ASSERT_EQUALS("", errout.str()); } + void clarifyCondition4() // ticket #3110 + { + check("typedef double SomeType;\n" + "typedef std::pair PairType;\n" + "struct S\n" + "{\n" + " bool operator()\n" + " ( PairType const & left\n" + " , PairType const & right) const\n" + " {\n" + " return (left.first < right.first);\n" + " }\n" + "}"); + ASSERT_EQUALS("", errout.str()); + } + void bitwiseOnBoolean() // 3062 { check("void f(_Bool a, _Bool b) {\n"