Bug hunting; Fix FP for struct with uninitialized members passed to function in C

This commit is contained in:
Daniel Marjamäki 2020-06-27 22:11:12 +02:00
parent c7a8f5217f
commit bcaf792e30
4 changed files with 7 additions and 2 deletions

View File

@ -250,6 +250,8 @@ static void uninit(const Token *tok, const ExprEngine::Value &value, ExprEngine:
return;
if (uninitData && argvar && !argvar->isConst())
return;
if (!uninitStructMember.empty() && dataBase->isC() && argvar && !argvar->isConst())
return;
} else if (uninitData) {
if (dataBase->settings->library.getFunction(parent->astOperand1()))
return;

View File

@ -371,6 +371,9 @@ namespace {
int recursion;
std::time_t startTime;
bool isC() const OVERRIDE { return tokenizer->isC(); }
bool isCPP() const OVERRIDE { return tokenizer->isCPP(); }
ExprEngine::ValuePtr executeContract(const Function *function, ExprEngine::ValuePtr(*executeExpression)(const Token*, Data&)) {
const auto it = settings->functionContracts.find(function->fullName());
if (it == settings->functionContracts.end())

View File

@ -79,6 +79,8 @@ namespace ExprEngine {
virtual std::string getNewSymbolName() = 0;
const std::string currentFunction;
const Settings * const settings;
virtual bool isC() const = 0;
virtual bool isCPP() const = 0;
virtual void reportError(const Token *tok,
Severity::SeverityType severity,
const char id[],

View File

@ -36,8 +36,6 @@ def get_error_lines(filename):
if testfile.find('uninit_') >= 0:
if linenr == 177:
linenr = 176
elif linenr == 200:
linenr = 225 # warn about function call
elif linenr == 241:
linenr = 242 # warn about usage
elif linenr == 266: