From f9cf1480127b2f9df586274c7b53451277cf1839 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Mon, 7 Oct 2013 18:41:07 +0200 Subject: [PATCH] CheckBool: Skip 'bool' type checking in C code --- lib/checkbool.cpp | 2 +- test/testbool.cpp | 14 ++++++++++++-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/lib/checkbool.cpp b/lib/checkbool.cpp index 79bbef269..8d39bceec 100644 --- a/lib/checkbool.cpp +++ b/lib/checkbool.cpp @@ -119,7 +119,7 @@ static bool isNonBoolStdType(const Variable* var) } void CheckBool::checkComparisonOfBoolWithInt() { - if (!_settings->isEnabled("warning")) + if (!_settings->isEnabled("warning") || !_tokenizer->isCPP()) return; const SymbolDatabase* const symbolDatabase = _tokenizer->getSymbolDatabase(); diff --git a/test/testbool.cpp b/test/testbool.cpp index 4febc3b96..5fa9d3577 100644 --- a/test/testbool.cpp +++ b/test/testbool.cpp @@ -58,7 +58,7 @@ private: TEST_CASE(checkComparisonOfFuncReturningBool6); } - void check(const char code[], bool experimental = false) { + void check(const char code[], bool experimental = false, const char filename[] = "test.cpp") { // Clear the error buffer.. errout.str(""); @@ -71,7 +71,7 @@ private: // Tokenize.. Tokenizer tokenizer(&settings, this); std::istringstream istr(code); - tokenizer.tokenize(istr, "test.cpp"); + tokenizer.tokenize(istr, filename); // Check... CheckBool checkBool(&tokenizer, &settings, this); @@ -312,6 +312,16 @@ private: check("int f() { return (!a+b