Verification; uninitialized local variable
This commit is contained in:
parent
c86a2d6e15
commit
f55d72e821
|
@ -1464,8 +1464,7 @@ static void execute(const Token *start, const Token *end, Data &data)
|
|||
tok = tok->tokAt(2);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if (tok->variable()->isArray()) {
|
||||
} else if (tok->variable()->isArray()) {
|
||||
data.assignValue(tok, tok->varId(), std::make_shared<ExprEngine::ArrayValue>(&data, tok->variable()));
|
||||
if (Token::Match(tok, "%name% ["))
|
||||
tok = tok->linkAt(1);
|
||||
|
@ -1657,7 +1656,11 @@ static ExprEngine::ValuePtr createVariableValue(const Variable &var, Data &data)
|
|||
if (var.isArray())
|
||||
return std::make_shared<ExprEngine::ArrayValue>(&data, &var);
|
||||
if (valueType->isIntegral() || valueType->isFloat()) {
|
||||
auto value = getValueRangeFromValueType(data.getNewSymbolName(), valueType, *data.settings);
|
||||
ExprEngine::ValuePtr value;
|
||||
if (var.isLocal() && !var.isStatic())
|
||||
value = std::make_shared<ExprEngine::UninitValue>();
|
||||
else
|
||||
value = getValueRangeFromValueType(data.getNewSymbolName(), valueType, *data.settings);
|
||||
data.addConstraints(value, var.nameToken());
|
||||
return value;
|
||||
}
|
||||
|
|
|
@ -16,6 +16,12 @@ int array2() {
|
|||
return a[2][3];
|
||||
}
|
||||
|
||||
void local1() {
|
||||
int x;
|
||||
// cppcheck-suppress verificationUninit
|
||||
return x;
|
||||
}
|
||||
|
||||
int pointer1(int *p) {
|
||||
// cppcheck-suppress verificationUninit
|
||||
return *p;
|
||||
|
|
Loading…
Reference in New Issue