checkFloatToIntegerOverflow: check all calculations, not only in function bodies
This commit is contained in:
parent
9268c2034a
commit
840c7eb258
|
@ -344,11 +344,7 @@ void CheckType::longCastReturnError(const Token *tok)
|
|||
|
||||
void CheckType::checkFloatToIntegerOverflow()
|
||||
{
|
||||
const SymbolDatabase *symbolDatabase = _tokenizer->getSymbolDatabase();
|
||||
const std::size_t functions = symbolDatabase->functionScopes.size();
|
||||
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()) {
|
||||
for (const Token *tok = _tokenizer->tokens(); tok; tok = tok->next()) {
|
||||
const ValueType *vtint, *vtfloat;
|
||||
const std::list<ValueFlow::Value> *floatValues;
|
||||
|
||||
|
@ -405,7 +401,6 @@ void CheckType::checkFloatToIntegerOverflow()
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CheckType::floatToIntegerOverflowError(const Token *tok, const ValueFlow::Value &value)
|
||||
|
|
|
@ -235,6 +235,9 @@ private:
|
|||
}
|
||||
|
||||
void checkFloatToIntegerOverflow() {
|
||||
check("x = (int)1E100;");
|
||||
ASSERT_EQUALS("[test.cpp:1]: (error) Undefined behaviour: float () to integer conversion overflow.\n", removeFloat(errout.str()));
|
||||
|
||||
check("void f(void) {\n"
|
||||
" return (int)1E100;\n"
|
||||
"}\n");
|
||||
|
|
Loading…
Reference in New Issue