Merge pull request #6640 from ethereum/smt_inherited_state_vars

[SMTChecker] Fix ICE in inherited state var
This commit is contained in:
chriseth 2019-05-02 10:49:34 +02:00 committed by GitHub
commit 73484ccaf2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 62 additions and 2 deletions

View File

@ -4,10 +4,12 @@ Language Features:
Compiler Features:
* SMTChecker: Support inherited state variables.
Bugfixes:
* SMTChecker: Fix bad cast in base constructor modifier.
* SMTChecker: Fix internal error when visiting state variable inherited from base class.

View File

@ -78,8 +78,10 @@ void SMTChecker::analyze(SourceUnit const& _source, shared_ptr<Scanner> const& _
bool SMTChecker::visit(ContractDefinition const& _contract)
{
for (auto _var : _contract.stateVariables())
createVariable(*_var);
for (auto const& contract: _contract.annotation().linearizedBaseContracts)
for (auto var : contract->stateVariables())
if (*contract == _contract || var->isVisibleInDerivedContracts())
createVariable(*var);
return true;
}

View File

@ -0,0 +1,17 @@
pragma experimental SMTChecker;
contract Base {
uint x;
uint z;
uint private t;
}
contract C is Base {
function f(uint y) public {
require(x < 10);
require(y < 100);
z = x + y;
assert(z < 150);
}
}
// ----

View File

@ -0,0 +1,21 @@
pragma experimental SMTChecker;
contract Base1 {
uint x;
uint private t;
}
contract Base2 is Base1 {
uint z;
uint private t;
}
contract C is Base2 {
function f(uint y) public {
require(x < 10);
require(y < 100);
z = x + y;
assert(z < 150);
}
}
// ----

View File

@ -0,0 +1,18 @@
pragma experimental SMTChecker;
contract Base {
uint x;
uint private t;
}
contract C is Base {
uint private z;
function f(uint y) public {
require(x < 10);
require(y < 100);
z = x + y;
assert(z < 150);
}
}
// ----