From 77e9106ec0fdd5f0bb8961f82ec96d8235896dcd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Tue, 22 May 2012 19:01:21 +0200 Subject: [PATCH] Fixed #3634 (False positive: compareBoolExpressionWithInt when using boost::tuples) --- lib/checkother.cpp | 6 ++++++ test/testother.cpp | 7 +++++++ 2 files changed, 13 insertions(+) diff --git a/lib/checkother.cpp b/lib/checkother.cpp index 6d9c6002e..d5fa4d410 100644 --- a/lib/checkother.cpp +++ b/lib/checkother.cpp @@ -2878,6 +2878,12 @@ void CheckOther::checkComparisonOfBoolExpressionWithInt() const SymbolDatabase* symbolDatabase = _tokenizer->getSymbolDatabase(); for (const Token *tok = _tokenizer->tokens(); tok; tok = tok->next()) { + // Skip template parameters + if (tok->str() == "<" && tok->link()) { + tok = tok->link(); + continue; + } + const Token* numTok = 0; const Token* opTok = 0; char op = 0; diff --git a/test/testother.cpp b/test/testother.cpp index 733b8622f..f0ac608d7 100644 --- a/test/testother.cpp +++ b/test/testother.cpp @@ -124,6 +124,7 @@ private: TEST_CASE(comparisonOfBoolExpressionWithInt1); TEST_CASE(comparisonOfBoolExpressionWithInt2); + TEST_CASE(comparisonOfBoolExpressionWithInt3); TEST_CASE(incorrectStringCompare); @@ -3041,6 +3042,12 @@ private: ASSERT_EQUALS("", errout.str()); } + void comparisonOfBoolExpressionWithInt3() { + check("int f(int x) {\n" + " return t<0>() && x;\n" + "}"); + ASSERT_EQUALS("", errout.str()); + } void memsetZeroBytes() { check("void f() {\n"