diff --git a/lib/checkother.cpp b/lib/checkother.cpp index 3b9d6b3f8..01babac1d 100644 --- a/lib/checkother.cpp +++ b/lib/checkother.cpp @@ -189,6 +189,15 @@ void CheckOther::clarifyCondition() Token::simpleMatch(tok2->previous(), "const &"))) continue; + // #3609 - CWinTraits::.. + if (Token::Match(tok->previous(), "%var% <")) { + const Token *tok3 = tok2; + while (Token::Match(tok3, "[&|^] %var%")) + tok3 = tok3->tokAt(2); + if (Token::Match(tok3, ",|>")) + continue; + } + clarifyConditionError(tok,false,true); } } diff --git a/test/testother.cpp b/test/testother.cpp index f911840df..3615563fc 100644 --- a/test/testother.cpp +++ b/test/testother.cpp @@ -128,6 +128,7 @@ private: TEST_CASE(clarifyCondition2); // if (a & b == c) TEST_CASE(clarifyCondition3); // if (! a & b) TEST_CASE(clarifyCondition4); // ticket #3110 + TEST_CASE(clarifyCondition5); // #3609 CWinTraits.. TEST_CASE(bitwiseOnBoolean); // if (bool & bool) TEST_CASE(comparisonOfBoolExpressionWithInt1); @@ -3541,6 +3542,11 @@ private: ASSERT_EQUALS("", errout.str()); } + void clarifyCondition5() { // ticket #3609 (using | in template instantiation) + check("CWinTraits::GetWndStyle(0);"); + ASSERT_EQUALS("", errout.str()); + } + void bitwiseOnBoolean() { // 3062 check("void f(_Bool a, _Bool b) {\n" " if(a & b) {}\n"