checkSignConversion: dont warn for + and -
This commit is contained in:
parent
0e55f12140
commit
8cbd013d7f
|
@ -225,7 +225,7 @@ void CheckType::checkSignConversion()
|
|||
for (std::size_t i = 0; i < functions; ++i) {
|
||||
const Scope * scope = symbolDatabase->functionScopes[i];
|
||||
for (const Token* tok = scope->classStart->next(); tok != scope->classEnd; tok = tok->next()) {
|
||||
if (!tok->isArithmeticalOp())
|
||||
if (!tok->isArithmeticalOp() || Token::Match(tok,"+|-"))
|
||||
continue;
|
||||
|
||||
unsigned int size = 0;
|
||||
|
|
|
@ -116,6 +116,13 @@ private:
|
|||
"}\n"
|
||||
"void f2() { f1(-4); }");
|
||||
ASSERT_EQUALS("[test.cpp:1]: (warning) Suspicious code: sign conversion of x in calculation, even though x can have a negative value\n", errout.str());
|
||||
|
||||
// Dont warn for + and -
|
||||
check("void f1(int x) {"
|
||||
" a = x + 5U;\n"
|
||||
"}\n"
|
||||
"void f2() { f1(-4); }");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue