[SMTChecker] Fix ICE on compound assignment to array index

This commit is contained in:
Leonardo Alt 2020-07-16 16:47:36 +02:00
parent f9753a5101
commit 672633af0a
6 changed files with 53 additions and 8 deletions

View File

@ -10,6 +10,7 @@ Compiler Features:
Bugfixes:
* SMTChecker: Fix internal error when using bitwise operators on fixed bytes type.
* SMTChecker: Fix internal error when using compound bitwise operator assignments on array indices inside branches.
* Type Checker: Fix overload resolution in combination with ``{value: ...}``.
* Type Checker: Fix internal compiler error related to oversized types.
* Code Generator: Avoid double cleanup when copying to memory.

View File

@ -363,8 +363,12 @@ void SMTEncoder::endVisit(Assignment const& _assignment)
Token op = _assignment.assignmentOperator();
if (op != Token::Assign && !compoundOps.count(op))
{
Expression const* identifier = &_assignment.leftHandSide();
if (auto const* indexAccess = dynamic_cast<IndexAccess const*>(identifier))
identifier = leftmostBase(*indexAccess);
// Give it a new index anyway to keep the SSA scheme sound.
if (auto varDecl = identifierToVariable(_assignment.leftHandSide()))
solAssert(identifier, "");
if (auto varDecl = identifierToVariable(*identifier))
m_context.newValue(*varDecl);
m_errorReporter.warning(

View File

@ -1,13 +1,10 @@
pragma experimental SMTChecker;
contract C {
function f(bool b) public pure {
uint v = 0;
int[1] c;
function f(bool b) public {
if (b)
v |= 1;
assert(v == 1);
c[0] |= 1;
}
}
// ----
// Warning 9149: (106-112): Assertion checker does not yet implement this assignment operator.
// Warning 4661: (116-130): Assertion violation happens here
// Warning 9149: (97-106): Assertion checker does not yet implement this assignment operator.

View File

@ -0,0 +1,10 @@
pragma experimental SMTChecker;
contract C {
int[1][20] c;
function f(bool b) public {
if (b)
c[10][0] |= 1;
}
}
// ----
// Warning 9149: (101-114): Assertion checker does not yet implement this assignment operator.

View File

@ -0,0 +1,16 @@
pragma experimental SMTChecker;
contract C {
struct S {
uint x;
}
S s;
function f(bool b) public {
if (b)
s.x |= 1;
}
}
// ----
// Warning 8115: (71-74): Assertion checker does not yet support the type of this variable.
// Warning 7650: (117-120): Assertion checker does not yet support this expression.
// Warning 8364: (117-118): Assertion checker does not yet implement type struct C.S storage ref
// Warning 9149: (117-125): Assertion checker does not yet implement this assignment operator.

View File

@ -0,0 +1,17 @@
pragma experimental SMTChecker;
contract C {
struct S {
uint[] x;
}
S s;
function f(bool b) public {
if (b)
s.x[2] |= 1;
}
}
// ----
// Warning 8115: (73-76): Assertion checker does not yet support the type of this variable.
// Warning 7650: (119-122): Assertion checker does not yet support this expression.
// Warning 8364: (119-120): Assertion checker does not yet implement type struct C.S storage ref
// Warning 9118: (119-125): Assertion checker does not yet implement this expression.
// Warning 9149: (119-130): Assertion checker does not yet implement this assignment operator.