Skip to content

Commit

Permalink
Fix problem with non-value-typed variables.
Browse files Browse the repository at this point in the history
  • Loading branch information
chriseth authored and axic committed Nov 22, 2017
1 parent 19d5c42 commit 8538a25
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 14 deletions.
26 changes: 13 additions & 13 deletions libsolidity/formal/SMTChecker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -592,21 +592,17 @@ smt::CheckResult SMTChecker::checkSatisifable()
void SMTChecker::initializeLocalVariables(FunctionDefinition const& _function)
{
for (auto const& variable: _function.localVariables())
{
createVariable(*variable);
setZeroValue(*variable);
}
if (createVariable(*variable))
setZeroValue(*variable);

for (auto const& param: _function.parameters())
{
createVariable(*param);
setUnknownValue(*param);
}
if (createVariable(*param))
setUnknownValue(*param);

if (_function.returnParameterList())
for (auto const& retParam: _function.returnParameters())
{
createVariable(*retParam);
setZeroValue(*retParam);
}
if (createVariable(*retParam))
setZeroValue(*retParam);
}

void SMTChecker::resetVariables(vector<Declaration const*> _variables)
Expand All @@ -618,7 +614,7 @@ void SMTChecker::resetVariables(vector<Declaration const*> _variables)
}
}

void SMTChecker::createVariable(VariableDeclaration const& _varDecl)
bool SMTChecker::createVariable(VariableDeclaration const& _varDecl)
{
if (dynamic_cast<IntegerType const*>(_varDecl.type().get()))
{
Expand All @@ -628,12 +624,16 @@ void SMTChecker::createVariable(VariableDeclaration const& _varDecl)
m_currentSequenceCounter[&_varDecl] = 0;
m_nextFreeSequenceCounter[&_varDecl] = 1;
m_variables.emplace(&_varDecl, m_interface->newFunction(uniqueSymbol(_varDecl), smt::Sort::Int, smt::Sort::Int));
return true;
}
else
{
m_errorReporter.warning(
_varDecl.location(),
"Assertion checker does not yet support the type of this variable."
);
return false;
}
}

string SMTChecker::uniqueSymbol(Declaration const& _decl)
Expand Down
4 changes: 3 additions & 1 deletion libsolidity/formal/SMTChecker.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,9 @@ class SMTChecker: private ASTConstVisitor

void initializeLocalVariables(FunctionDefinition const& _function);
void resetVariables(std::vector<Declaration const*> _variables);
void createVariable(VariableDeclaration const& _varDecl);
/// Tries to create an uninitialized variable and returns true on success.
/// This fails if the type is not supported.
bool createVariable(VariableDeclaration const& _varDecl);

static std::string uniqueSymbol(Declaration const& _decl);
static std::string uniqueSymbol(Expression const& _expr);
Expand Down

0 comments on commit 8538a25

Please sign in to comment.