Fixed #9276 (FP literalWithCharPtrCompare)
This commit is contained in:
parent
120c572252
commit
44ff22f879
|
@ -181,6 +181,9 @@ void CheckString::checkSuspiciousStringCompare()
|
|||
else if (!Token::Match(litTok, "%char%|%num%|%str%"))
|
||||
continue;
|
||||
|
||||
if (mTokenizer->isCPP() && (!varTok->valueType() || !varTok->valueType()->isIntegral()))
|
||||
continue;
|
||||
|
||||
// Pointer addition?
|
||||
if (varTok->str() == "+" && mTokenizer->isC()) {
|
||||
const Token * const tokens[2] = { varTok->astOperand1(), varTok->astOperand2() };
|
||||
|
|
|
@ -393,6 +393,13 @@ private:
|
|||
" if (example.buffer == \"test\") ;\n"
|
||||
"}\n", "test.c");
|
||||
ASSERT_EQUALS("[test.c:6]: (warning) String literal compared with variable 'example.buffer'. Did you intend to use strcmp() instead?\n", errout.str());
|
||||
|
||||
// #9726
|
||||
check("void f(std::vector<std::string> theArgs) {\n"
|
||||
" std::string arg1(*theArgs.begin());\n"
|
||||
" if(arg1 == \"aaa\") {}\n"
|
||||
"}");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void suspiciousStringCompare_char() {
|
||||
|
|
Loading…
Reference in New Issue