mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
[SMTChecker] Support assignments to m-d arrays and mappings
This commit is contained in:
parent
302a51a58c
commit
8a42e3f87a
@ -5,6 +5,7 @@ Language Features:
|
|||||||
|
|
||||||
Compiler Features:
|
Compiler Features:
|
||||||
* Code Generator: Use SELFBALANCE for ``address(this).balance`` if using Istanbul EVM
|
* Code Generator: Use SELFBALANCE for ``address(this).balance`` if using Istanbul EVM
|
||||||
|
* SMTChecker: Support assignments to multi-dimensional arrays and mappings.
|
||||||
|
|
||||||
|
|
||||||
Bugfixes:
|
Bugfixes:
|
||||||
|
@ -774,8 +774,12 @@ void SMTEncoder::arrayAssignment()
|
|||||||
|
|
||||||
void SMTEncoder::arrayIndexAssignment(Expression const& _expr, smt::Expression const& _rightHandSide)
|
void SMTEncoder::arrayIndexAssignment(Expression const& _expr, smt::Expression const& _rightHandSide)
|
||||||
{
|
{
|
||||||
auto const& indexAccess = dynamic_cast<IndexAccess const&>(_expr);
|
auto toStore = _rightHandSide;
|
||||||
if (auto const& id = dynamic_cast<Identifier const*>(&indexAccess.baseExpression()))
|
auto indexAccess = dynamic_cast<IndexAccess const*>(&_expr);
|
||||||
|
solAssert(indexAccess, "");
|
||||||
|
while (true)
|
||||||
|
{
|
||||||
|
if (auto const& id = dynamic_cast<Identifier const*>(&indexAccess->baseExpression()))
|
||||||
{
|
{
|
||||||
auto varDecl = identifierToVariable(*id);
|
auto varDecl = identifierToVariable(*id);
|
||||||
solAssert(varDecl, "");
|
solAssert(varDecl, "");
|
||||||
@ -816,36 +820,33 @@ void SMTEncoder::arrayIndexAssignment(Expression const& _expr, smt::Expression c
|
|||||||
|
|
||||||
smt::Expression store = smt::Expression::store(
|
smt::Expression store = smt::Expression::store(
|
||||||
m_context.variable(*varDecl)->currentValue(),
|
m_context.variable(*varDecl)->currentValue(),
|
||||||
expr(*indexAccess.indexExpression()),
|
expr(*indexAccess->indexExpression()),
|
||||||
_rightHandSide
|
toStore
|
||||||
);
|
);
|
||||||
m_context.addAssertion(m_context.newValue(*varDecl) == store);
|
m_context.addAssertion(m_context.newValue(*varDecl) == store);
|
||||||
// Update the SMT select value after the assignment,
|
// Update the SMT select value after the assignment,
|
||||||
// necessary for sound models.
|
// necessary for sound models.
|
||||||
defineExpr(indexAccess, smt::Expression::select(
|
defineExpr(*indexAccess, smt::Expression::select(
|
||||||
m_context.variable(*varDecl)->currentValue(),
|
m_context.variable(*varDecl)->currentValue(),
|
||||||
expr(*indexAccess.indexExpression())
|
expr(*indexAccess->indexExpression())
|
||||||
));
|
));
|
||||||
}
|
|
||||||
else if (dynamic_cast<IndexAccess const*>(&indexAccess.baseExpression()))
|
|
||||||
{
|
|
||||||
auto identifier = dynamic_cast<Identifier const*>(leftmostBase(indexAccess));
|
|
||||||
if (identifier)
|
|
||||||
{
|
|
||||||
auto varDecl = identifierToVariable(*identifier);
|
|
||||||
m_context.newValue(*varDecl);
|
|
||||||
}
|
|
||||||
|
|
||||||
m_errorReporter.warning(
|
break;
|
||||||
indexAccess.location(),
|
}
|
||||||
"Assertion checker does not yet implement assignments to multi-dimensional mappings or arrays."
|
else if (auto base = dynamic_cast<IndexAccess const*>(&indexAccess->baseExpression()))
|
||||||
);
|
{
|
||||||
|
toStore = smt::Expression::store(expr(*base), expr(*indexAccess->indexExpression()), toStore);
|
||||||
|
indexAccess = base;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
m_errorReporter.warning(
|
m_errorReporter.warning(
|
||||||
_expr.location(),
|
_expr.location(),
|
||||||
"Assertion checker does not yet implement this expression."
|
"Assertion checker does not yet implement this expression."
|
||||||
);
|
);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SMTEncoder::defineGlobalVariable(string const& _name, Expression const& _expr, bool _increaseIndex)
|
void SMTEncoder::defineGlobalVariable(string const& _name, Expression const& _expr, bool _increaseIndex)
|
||||||
|
@ -11,6 +11,4 @@ contract C
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// ----
|
// ----
|
||||||
// Warning: (90-97): Assertion checker does not yet implement assignments to multi-dimensional mappings or arrays.
|
|
||||||
// Warning: (115-122): Assertion checker does not yet implement assignments to multi-dimensional mappings or arrays.
|
|
||||||
// Warning: (130-149): Assertion violation happens here
|
// Warning: (130-149): Assertion violation happens here
|
||||||
|
@ -11,6 +11,4 @@ contract C
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// ----
|
// ----
|
||||||
// Warning: (92-102): Assertion checker does not yet implement assignments to multi-dimensional mappings or arrays.
|
|
||||||
// Warning: (120-130): Assertion checker does not yet implement assignments to multi-dimensional mappings or arrays.
|
|
||||||
// Warning: (138-160): Assertion violation happens here
|
// Warning: (138-160): Assertion violation happens here
|
||||||
|
@ -13,7 +13,3 @@ contract C
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// ----
|
// ----
|
||||||
// Warning: (90-97): Assertion checker does not yet implement assignments to multi-dimensional mappings or arrays.
|
|
||||||
// Warning: (115-122): Assertion checker does not yet implement assignments to multi-dimensional mappings or arrays.
|
|
||||||
// Warning: (138-145): Assertion checker does not yet implement assignments to multi-dimensional mappings or arrays.
|
|
||||||
// Warning: (153-172): Assertion violation happens here
|
|
||||||
|
@ -13,7 +13,3 @@ contract C
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// ----
|
// ----
|
||||||
// Warning: (92-102): Assertion checker does not yet implement assignments to multi-dimensional mappings or arrays.
|
|
||||||
// Warning: (120-130): Assertion checker does not yet implement assignments to multi-dimensional mappings or arrays.
|
|
||||||
// Warning: (146-156): Assertion checker does not yet implement assignments to multi-dimensional mappings or arrays.
|
|
||||||
// Warning: (164-186): Assertion violation happens here
|
|
||||||
|
@ -17,15 +17,15 @@ contract C
|
|||||||
// Warning: (124-130): Assertion checker does not yet support this expression.
|
// Warning: (124-130): Assertion checker does not yet support this expression.
|
||||||
// Warning: (124-128): Assertion checker does not yet implement type struct C.S memory
|
// Warning: (124-128): Assertion checker does not yet implement type struct C.S memory
|
||||||
// Warning: (124-133): Assertion checker does not yet implement this expression.
|
// Warning: (124-133): Assertion checker does not yet implement this expression.
|
||||||
// Warning: (124-136): Assertion checker does not yet implement assignments to multi-dimensional mappings or arrays.
|
// Warning: (124-136): Assertion checker does not yet implement this expression.
|
||||||
// Warning: (154-160): Assertion checker does not yet support this expression.
|
// Warning: (154-160): Assertion checker does not yet support this expression.
|
||||||
// Warning: (154-158): Assertion checker does not yet implement type struct C.S memory
|
// Warning: (154-158): Assertion checker does not yet implement type struct C.S memory
|
||||||
// Warning: (154-163): Assertion checker does not yet implement this expression.
|
// Warning: (154-163): Assertion checker does not yet implement this expression.
|
||||||
// Warning: (154-166): Assertion checker does not yet implement assignments to multi-dimensional mappings or arrays.
|
// Warning: (154-166): Assertion checker does not yet implement this expression.
|
||||||
// Warning: (182-188): Assertion checker does not yet support this expression.
|
// Warning: (182-188): Assertion checker does not yet support this expression.
|
||||||
// Warning: (182-186): Assertion checker does not yet implement type struct C.S memory
|
// Warning: (182-186): Assertion checker does not yet implement type struct C.S memory
|
||||||
// Warning: (182-191): Assertion checker does not yet implement this expression.
|
// Warning: (182-191): Assertion checker does not yet implement this expression.
|
||||||
// Warning: (182-194): Assertion checker does not yet implement assignments to multi-dimensional mappings or arrays.
|
// Warning: (182-194): Assertion checker does not yet implement this expression.
|
||||||
// Warning: (209-215): Assertion checker does not yet support this expression.
|
// Warning: (209-215): Assertion checker does not yet support this expression.
|
||||||
// Warning: (209-213): Assertion checker does not yet implement type struct C.S memory
|
// Warning: (209-213): Assertion checker does not yet implement type struct C.S memory
|
||||||
// Warning: (209-218): Assertion checker does not yet implement this expression.
|
// Warning: (209-218): Assertion checker does not yet implement this expression.
|
||||||
|
@ -10,5 +10,3 @@ contract C
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// ----
|
// ----
|
||||||
// Warning: (134-145): Assertion checker does not yet implement assignments to multi-dimensional mappings or arrays.
|
|
||||||
// Warning: (154-178): Assertion violation happens here
|
|
||||||
|
@ -10,5 +10,4 @@ contract C
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// ----
|
// ----
|
||||||
// Warning: (134-145): Assertion checker does not yet implement assignments to multi-dimensional mappings or arrays.
|
|
||||||
// Warning: (154-178): Assertion violation happens here
|
// Warning: (154-178): Assertion violation happens here
|
||||||
|
@ -10,5 +10,3 @@ contract C
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// ----
|
// ----
|
||||||
// Warning: (152-167): Assertion checker does not yet implement assignments to multi-dimensional mappings or arrays.
|
|
||||||
// Warning: (176-204): Assertion violation happens here
|
|
||||||
|
@ -10,5 +10,4 @@ contract C
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// ----
|
// ----
|
||||||
// Warning: (152-167): Assertion checker does not yet implement assignments to multi-dimensional mappings or arrays.
|
|
||||||
// Warning: (176-204): Assertion violation happens here
|
// Warning: (176-204): Assertion violation happens here
|
||||||
|
@ -19,15 +19,15 @@ contract C
|
|||||||
// Warning: (117-120): Assertion checker does not yet support this expression.
|
// Warning: (117-120): Assertion checker does not yet support this expression.
|
||||||
// Warning: (117-118): Assertion checker does not yet implement type struct C.S memory
|
// Warning: (117-118): Assertion checker does not yet implement type struct C.S memory
|
||||||
// Warning: (117-123): Assertion checker does not yet implement this expression.
|
// Warning: (117-123): Assertion checker does not yet implement this expression.
|
||||||
// Warning: (117-126): Assertion checker does not yet implement assignments to multi-dimensional mappings or arrays.
|
// Warning: (117-126): Assertion checker does not yet implement this expression.
|
||||||
// Warning: (144-147): Assertion checker does not yet support this expression.
|
// Warning: (144-147): Assertion checker does not yet support this expression.
|
||||||
// Warning: (144-145): Assertion checker does not yet implement type struct C.S memory
|
// Warning: (144-145): Assertion checker does not yet implement type struct C.S memory
|
||||||
// Warning: (144-150): Assertion checker does not yet implement this expression.
|
// Warning: (144-150): Assertion checker does not yet implement this expression.
|
||||||
// Warning: (144-153): Assertion checker does not yet implement assignments to multi-dimensional mappings or arrays.
|
// Warning: (144-153): Assertion checker does not yet implement this expression.
|
||||||
// Warning: (169-172): Assertion checker does not yet support this expression.
|
// Warning: (169-172): Assertion checker does not yet support this expression.
|
||||||
// Warning: (169-170): Assertion checker does not yet implement type struct C.S memory
|
// Warning: (169-170): Assertion checker does not yet implement type struct C.S memory
|
||||||
// Warning: (169-175): Assertion checker does not yet implement this expression.
|
// Warning: (169-175): Assertion checker does not yet implement this expression.
|
||||||
// Warning: (169-178): Assertion checker does not yet implement assignments to multi-dimensional mappings or arrays.
|
// Warning: (169-178): Assertion checker does not yet implement this expression.
|
||||||
// Warning: (193-196): Assertion checker does not yet support this expression.
|
// Warning: (193-196): Assertion checker does not yet support this expression.
|
||||||
// Warning: (193-194): Assertion checker does not yet implement type struct C.S memory
|
// Warning: (193-194): Assertion checker does not yet implement type struct C.S memory
|
||||||
// Warning: (193-199): Assertion checker does not yet implement this expression.
|
// Warning: (193-199): Assertion checker does not yet implement this expression.
|
||||||
|
@ -18,15 +18,15 @@ contract C
|
|||||||
// Warning: (124-127): Assertion checker does not yet support this expression.
|
// Warning: (124-127): Assertion checker does not yet support this expression.
|
||||||
// Warning: (124-125): Assertion checker does not yet implement type struct C.S memory
|
// Warning: (124-125): Assertion checker does not yet implement type struct C.S memory
|
||||||
// Warning: (124-130): Assertion checker does not yet implement this expression.
|
// Warning: (124-130): Assertion checker does not yet implement this expression.
|
||||||
// Warning: (124-136): Assertion checker does not yet implement assignments to multi-dimensional mappings or arrays.
|
// Warning: (124-136): Assertion checker does not yet implement this expression.
|
||||||
// Warning: (154-157): Assertion checker does not yet support this expression.
|
// Warning: (154-157): Assertion checker does not yet support this expression.
|
||||||
// Warning: (154-155): Assertion checker does not yet implement type struct C.S memory
|
// Warning: (154-155): Assertion checker does not yet implement type struct C.S memory
|
||||||
// Warning: (154-160): Assertion checker does not yet implement this expression.
|
// Warning: (154-160): Assertion checker does not yet implement this expression.
|
||||||
// Warning: (154-166): Assertion checker does not yet implement assignments to multi-dimensional mappings or arrays.
|
// Warning: (154-166): Assertion checker does not yet implement this expression.
|
||||||
// Warning: (182-185): Assertion checker does not yet support this expression.
|
// Warning: (182-185): Assertion checker does not yet support this expression.
|
||||||
// Warning: (182-183): Assertion checker does not yet implement type struct C.S memory
|
// Warning: (182-183): Assertion checker does not yet implement type struct C.S memory
|
||||||
// Warning: (182-188): Assertion checker does not yet implement this expression.
|
// Warning: (182-188): Assertion checker does not yet implement this expression.
|
||||||
// Warning: (182-194): Assertion checker does not yet implement assignments to multi-dimensional mappings or arrays.
|
// Warning: (182-194): Assertion checker does not yet implement this expression.
|
||||||
// Warning: (209-212): Assertion checker does not yet support this expression.
|
// Warning: (209-212): Assertion checker does not yet support this expression.
|
||||||
// Warning: (209-210): Assertion checker does not yet implement type struct C.S memory
|
// Warning: (209-210): Assertion checker does not yet implement type struct C.S memory
|
||||||
// Warning: (209-215): Assertion checker does not yet implement this expression.
|
// Warning: (209-215): Assertion checker does not yet implement this expression.
|
||||||
|
Loading…
Reference in New Issue
Block a user