fix bug in previous commit: fix #311 (add detection of duplicated if else-cases)

This commit is contained in:
Robert Reif 2011-04-09 16:34:16 -04:00
parent 7e403ae210
commit d22fcb8184
2 changed files with 6 additions and 3 deletions

View File

@ -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();

View File

@ -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"