diff --git a/lib/checkother.cpp b/lib/checkother.cpp index ceaa9501b..31c076398 100644 --- a/lib/checkother.cpp +++ b/lib/checkother.cpp @@ -3047,9 +3047,6 @@ void CheckOther::checkIncorrectStringCompare() static const std::string stringifyTokens(const Token *start, const Token *end) { - if (start == end) - return ""; - const Token *tok = start; std::string stringified = tok->str(); diff --git a/test/testother.cpp b/test/testother.cpp index 134a0b8ff..49ec12cbe 100644 --- a/test/testother.cpp +++ b/test/testother.cpp @@ -2403,6 +2403,12 @@ private: void duplicateIf() { + check("void f(int a, int &b) {\n" + " if (a) { b = 1; }\n" + " else if (a) { b = 2; }\n" + "}"); + ASSERT_EQUALS("[test.cpp:3] -> [test.cpp:2]: (style) Found duplicate if expressions.\n", errout.str()); + check("void f(int a, int &b) {\n" " if (a == 1) { b = 1; }\n" " else if (a == 2) { b = 2; }\n"