Fix FP, conversion of char literal '\0' to boolean is not true
This commit is contained in:
parent
fc7aab220e
commit
f2e7071922
|
@ -307,7 +307,7 @@ void CheckString::checkIncorrectStringCompare()
|
|||
}
|
||||
} else if (Token::Match(tok, "&&|%oror%|( %str%|%char% &&|%oror%|)") && !Token::Match(tok, "( %str%|%char% )")) {
|
||||
incorrectStringBooleanError(tok->next(), tok->strAt(1));
|
||||
} else if (Token::Match(tok, "if|while ( %str%|%char% )")) {
|
||||
} else if (Token::Match(tok, "if|while ( %str%|%char% )") && !tok->tokAt(2)->getValue(0)) {
|
||||
incorrectStringBooleanError(tok->tokAt(2), tok->strAt(2));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -591,6 +591,11 @@ private:
|
|||
"[test.cpp:3]: (warning) Conversion of char literal 'b' to bool always evaluates to true.\n"
|
||||
"[test.cpp:4]: (warning) Conversion of char literal 'c' to bool always evaluates to true.\n"
|
||||
, errout.str());
|
||||
|
||||
check("void f() {\n"
|
||||
" if('\\0'){}\n"
|
||||
"}");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void deadStrcmp() {
|
||||
|
|
Loading…
Reference in New Issue