[SMTChecker] Add support to constructors

This commit is contained in:
Leonardo Alt
2019-11-28 14:43:23 +01:00
parent 301215f186
commit a352abe00d
46 changed files with 1051 additions and 172 deletions
@@ -53,6 +53,5 @@ contract MyConc{
// ----
// Warning: (773-792): This declaration shadows an existing declaration.
// Warning: (1009-1086): Function state mutability can be restricted to view
// Warning: (874-879): Underflow (resulting value less than 0) happens here.
// Warning: (874-879): Overflow (resulting value larger than 2**256 - 1) happens here.
// Warning: (985-1002): Underflow (resulting value less than 0) happens here.
// Warning: (985-1002): Overflow (resulting value larger than 2**256 - 1) happens here.
@@ -137,4 +137,3 @@ contract PropagateThroughReturnValue {
// Warning: (748-755): Assertion checker does not yet support this expression.
// Warning: (748-751): Assertion checker does not yet implement type struct Reference.St storage pointer
// Warning: (748-770): Assertion checker does not yet implement such assignments.
// Warning: (849-905): Assertion checker does not yet support constructors.
@@ -13,5 +13,3 @@ contract B is A {
}
}
// ----
// Warning: (56-90): Assertion checker does not yet support constructors.
// Warning: (113-151): Assertion checker does not yet support constructors.
@@ -1,6 +1,16 @@
pragma experimental SMTChecker;
contract C { constructor(uint) public {} }
contract A is C { constructor() C(2) public {} }
contract C {
uint a;
constructor(uint x) public {
a = x;
}
}
contract A is C {
constructor() C(2) public {
assert(a == 2);
assert(a == 3);
}
}
// ----
// Warning: (45-72): Assertion checker does not yet support constructors.
// Warning: (93-121): Assertion checker does not yet support constructors.
// Warning: (166-180): Assertion violation happens here
@@ -1,10 +1,7 @@
pragma experimental SMTChecker;
contract C { constructor(uint) public {} }
contract A is C { constructor() C(2) public {} }
contract B is C { constructor() C(3) public {} }
contract J is C { constructor() C(3) public {} }
contract C { uint a; constructor(uint x) public { a = x; } }
contract A is C { constructor() C(2) public { assert(a == 2); } }
contract B is C { constructor() C(3) public { assert(a == 3); } }
contract J is C { constructor() C(3) public { assert(a == 4); } }
// ----
// Warning: (45-72): Assertion checker does not yet support constructors.
// Warning: (93-121): Assertion checker does not yet support constructors.
// Warning: (142-170): Assertion checker does not yet support constructors.
// Warning: (191-219): Assertion checker does not yet support constructors.
// Warning: (271-285): Assertion violation happens here
@@ -0,0 +1,22 @@
pragma experimental SMTChecker;
contract C {
uint a;
constructor(uint x) public {
a = x;
}
}
contract B is C {
constructor(uint x) public {
a = x;
}
}
contract A is B {
constructor(uint x) B(x) C(x + 2) public {
assert(a == x);
assert(a == x + 1);
}
}
// ----
// Warning: (244-262): Assertion violation happens here
@@ -0,0 +1,23 @@
pragma experimental SMTChecker;
contract C {
uint a;
constructor(uint x) public {
a = x;
}
}
contract B is C {
constructor(uint x) public {
a = x;
}
}
contract A is B {
constructor(uint x) C(x + 2) B(x + 1) public {
assert(a == x + 1);
}
}
// ----
// Warning: (212-217): Overflow (resulting value larger than 2**256 - 1) happens here
// Warning: (203-208): Overflow (resulting value larger than 2**256 - 1) happens here
// Warning: (242-247): Overflow (resulting value larger than 2**256 - 1) happens here
@@ -0,0 +1,29 @@
pragma experimental SMTChecker;
contract C {
uint a;
constructor(uint x) public {
a = x;
}
}
contract B1 is C {
constructor(uint x) public {
a = x;
}
}
contract B2 is C {
constructor(uint x) C(x + 2) public {
a = x;
}
}
contract A is B2, B1 {
constructor(uint x) B2(x) B1(x) public {
assert(a == x);
assert(a == x + 1);
}
}
// ----
// Warning: (205-210): Overflow (resulting value larger than 2**256 - 1) happens here
// Warning: (321-339): Assertion violation happens here
@@ -0,0 +1,29 @@
pragma experimental SMTChecker;
contract C {
uint a;
constructor(uint x) public {
a = x;
}
}
contract B1 is C {
constructor(uint x) public {
a = x;
}
}
contract B2 is C {
constructor(uint x) C(x + 2) public {
a = x;
}
}
contract A is B2, B1 {
constructor(uint x) B1(x) B2(x) public {
assert(a == x);
assert(a == x + 1);
}
}
// ----
// Warning: (205-210): Overflow (resulting value larger than 2**256 - 1) happens here
// Warning: (321-339): Assertion violation happens here
@@ -0,0 +1,34 @@
pragma experimental SMTChecker;
contract C {
uint a;
constructor(uint x) public {
a = x;
}
}
contract B1 is C {
uint b1;
constructor(uint x) public {
b1 = x + a;
}
}
contract B2 is C {
uint b2;
constructor(uint x) C(x + 2) public {
b2 = x + a;
}
}
contract A is B2, B1 {
constructor(uint x) B2(x) B1(x) public {
assert(b1 == b2);
assert(b1 != b2);
}
}
// ----
// Warning: (165-170): Underflow (resulting value less than 0) happens here
// Warning: (165-170): Overflow (resulting value larger than 2**256 - 1) happens here
// Warning: (230-235): Overflow (resulting value larger than 2**256 - 1) happens here
// Warning: (253-258): Overflow (resulting value larger than 2**256 - 1) happens here
// Warning: (353-369): Assertion violation happens here
@@ -0,0 +1,23 @@
pragma experimental SMTChecker;
contract C {
uint a;
constructor() public {
a = 2;
}
}
contract B is C {
}
contract B2 is C {
}
contract A is B, B2 {
constructor(uint x) public {
assert(a == 2);
assert(a == 3);
}
}
// ----
// Warning: (171-177): Unused function parameter. Remove or comment out the variable name to silence this warning.
// Warning: (208-222): Assertion violation happens here
@@ -0,0 +1,19 @@
pragma experimental SMTChecker;
contract C {
uint a;
constructor() public {
a = 2;
}
}
contract B is C {
}
contract B2 is C {
constructor() public {
assert(a == 2);
}
}
contract A is B, B2 {
}
@@ -0,0 +1,22 @@
pragma experimental SMTChecker;
contract F {
uint a;
constructor() public {
a = 2;
}
}
contract E is F {}
contract D is E {}
contract C is D {}
contract B is C {}
contract A is B {
constructor(uint x) public {
assert(a == 2);
assert(a == 3);
}
}
// ----
// Warning: (201-207): Unused function parameter. Remove or comment out the variable name to silence this warning.
// Warning: (238-252): Assertion violation happens here
@@ -0,0 +1,20 @@
pragma experimental SMTChecker;
contract C {
uint a;
constructor() public {
a = 2;
}
}
contract B is C {
}
contract A is B {
constructor(uint x) B() public {
assert(a == 2);
assert(a == 3);
}
}
// ----
// Warning: (145-151): Unused function parameter. Remove or comment out the variable name to silence this warning.
// Warning: (186-200): Assertion violation happens here
@@ -0,0 +1,19 @@
pragma experimental SMTChecker;
contract C {
uint a;
constructor() public {
a = 2;
}
}
contract B is C {
}
contract A is B {
constructor(uint x) public {
assert(a == 3);
}
}
// ----
// Warning: (145-151): Unused function parameter. Remove or comment out the variable name to silence this warning.
// Warning: (164-178): Assertion violation happens here
@@ -0,0 +1,30 @@
pragma experimental SMTChecker;
contract F {
uint a;
constructor() public {
a = 2;
}
}
contract E is F {}
contract D is E {
constructor() public {
a = 3;
}
}
contract C is D {}
contract B is C {
constructor() public {
a = 4;
}
}
contract A is B {
constructor(uint x) public {
assert(a == 4);
assert(a == 5);
}
}
// ----
// Warning: (275-281): Unused function parameter. Remove or comment out the variable name to silence this warning.
// Warning: (312-326): Assertion violation happens here
@@ -0,0 +1,24 @@
pragma experimental SMTChecker;
contract F {
uint a;
constructor() public {
a = 2;
}
}
contract E is F {}
contract D is E {
constructor() public {
a = 3;
}
}
contract C is D {}
contract B is C {
constructor() public {
assert(a == 3);
a = 4;
}
}
contract A is B {
}
@@ -0,0 +1,29 @@
pragma experimental SMTChecker;
contract F {
uint a;
constructor(uint x) public {
a = x;
}
}
contract E is F {}
contract D is E {
constructor() public {
a = 3;
}
}
contract C is D {}
contract B is C {
constructor(uint x) F(x + 1) public {
}
}
contract A is B {
constructor(uint x) B(x) public {
assert(a == 3);
assert(a == 4);
}
}
// ----
// Warning: (234-239): Overflow (resulting value larger than 2**256 - 1) happens here
// Warning: (329-343): Assertion violation happens here
@@ -0,0 +1,27 @@
pragma experimental SMTChecker;
contract F {
uint a;
constructor(uint x) public {
a = x;
}
}
contract E is F {}
contract D is E {
constructor() public {
a = 3;
}
}
contract C is D {}
contract B is C {
constructor() F(1) public {
assert(a == 3);
assert(a == 2);
}
}
contract A is B {
}
// ----
// Warning: (260-274): Assertion violation happens here
// Warning: (260-274): Assertion violation happens here
@@ -0,0 +1,17 @@
pragma experimental SMTChecker;
contract C {
uint a;
modifier n { _; a = 7; }
constructor(uint x) n public {
a = x;
}
}
contract A is C {
modifier m { a = 5; _; }
constructor() C(2) public {
assert(a == 4);
}
}
// ----
// Warning: (202-216): Assertion violation happens here
@@ -0,0 +1,16 @@
pragma experimental SMTChecker;
contract C {
uint a;
constructor(uint x) public {
a = x;
}
}
contract A is C {
constructor() C(2) public {
assert(a == 0);
assert(C.a == 0);
}
}
// ----
// Warning: (148-162): Assertion violation happens here
@@ -0,0 +1,16 @@
pragma experimental SMTChecker;
contract C {
uint x;
constructor() public {
assert(x == 0);
x = 10;
}
function f(uint y) public view {
assert(y == x);
}
}
// ----
// Warning: (148-162): Assertion violation happens here
@@ -0,0 +1,16 @@
pragma experimental SMTChecker;
contract C {
uint x = 5;
constructor() public {
assert(x == 5);
x = 10;
}
function f(uint y) public view {
assert(y == x);
}
}
// ----
// Warning: (152-166): Assertion violation happens here
@@ -0,0 +1,18 @@
pragma experimental SMTChecker;
contract B {
uint x = 5;
}
contract C is B {
constructor() public {
assert(x == 5);
x = 10;
}
function f(uint y) public view {
assert(y == x);
}
}
// ----
// Warning: (172-186): Assertion violation happens here
@@ -0,0 +1,17 @@
pragma experimental SMTChecker;
contract C {
uint x = 5;
constructor(uint a, uint b) public {
assert(x == 5);
x = a + b;
}
function f(uint y) public view {
assert(y == x);
}
}
// ----
// Warning: (169-183): Assertion violation happens here
// Warning: (122-127): Overflow (resulting value larger than 2**256 - 1) happens here
@@ -0,0 +1,29 @@
pragma experimental SMTChecker;
contract F {
uint a;
constructor(uint x) public {
a = x;
}
}
contract E is F {}
contract D is E {
constructor() public {
a = 3;
}
}
contract C is D {}
contract B is C {
constructor(uint x) F(x + 1) public {
}
}
contract A is B {
constructor(uint x) B(x) public {
assert(a == 3);
assert(a == 4);
}
}
// ----
// Warning: (234-239): Overflow (resulting value larger than 2**256 - 1) happens here
// Warning: (329-343): Assertion violation happens here
@@ -0,0 +1,11 @@
pragma experimental SMTChecker;
contract C {
uint x = 2;
constructor () public {
assert(x == 2);
assert(x == 3);
}
}
// ----
// Warning: (104-118): Assertion violation happens here
@@ -0,0 +1,14 @@
pragma experimental SMTChecker;
contract C {
uint x = 2;
}
contract D is C {
constructor() public {
assert(x == 2);
assert(x == 3);
}
}
// ----
// Warning: (124-138): Assertion violation happens here
@@ -0,0 +1,22 @@
pragma experimental SMTChecker;
contract A {
uint x = 1;
}
contract B is A {
constructor() public { x = 2; }
}
contract C is B {
constructor() public { x = 3; }
}
contract D is C {
constructor() public {
assert(x == 3);
assert(x == 2);
}
}
// ----
// Warning: (232-246): Assertion violation happens here
@@ -0,0 +1,21 @@
pragma experimental SMTChecker;
contract A {
uint x = 1;
}
contract B is A {
constructor() public { x = 2; }
}
contract C is B {
}
contract D is C {
constructor() public {
assert(x == 2);
assert(x == 3);
}
}
// ----
// Warning: (199-213): Assertion violation happens here
@@ -0,0 +1,27 @@
pragma experimental SMTChecker;
contract C {
uint a;
constructor(uint x) public {
a = x;
}
}
contract B is C {
uint b;
constructor(uint x) public {
b = a + x;
}
}
contract A is B {
constructor(uint x) B(x) C(x + 2) public {
assert(a == x + 2);
assert(b == x + x + 2);
assert(a == x + 5);
}
}
// ----
// Warning: (162-167): Underflow (resulting value less than 0) happens here
// Warning: (162-167): Overflow (resulting value larger than 2**256 - 1) happens here
// Warning: (287-305): Assertion violation happens here
@@ -0,0 +1,26 @@
pragma experimental SMTChecker;
contract C {
uint a;
constructor(uint x) public {
a = x;
}
}
contract B is C {
uint b;
constructor(uint x) public {
b = x + 10;
}
}
contract A is B {
constructor(uint x) B(x) C(x + 2) public {
assert(a == x + 2);
assert(b == x + 10);
assert(b == x + 5);
}
}
// ----
// Warning: (162-168): Overflow (resulting value larger than 2**256 - 1) happens here
// Warning: (285-303): Assertion violation happens here
@@ -0,0 +1,20 @@
pragma experimental SMTChecker;
contract A {
uint x = 2;
}
contract B is A {
}
contract C is A {
}
contract D is B, C {
constructor() public {
assert(x == 2);
assert(x == 3);
}
}
// ----
// Warning: (169-183): Assertion violation happens here
@@ -0,0 +1,22 @@
pragma experimental SMTChecker;
contract A {
uint x = 1;
}
contract B is A {
constructor() public { x = 2; }
}
contract C is A {
constructor() public { x = 3; }
}
contract D is B, C {
constructor() public {
assert(x == 3);
assert(x == 4);
}
}
// ----
// Warning: (235-249): Assertion violation happens here
@@ -0,0 +1,17 @@
pragma experimental SMTChecker;
contract C {
uint x = f(2);
constructor () public {
assert(x == 2);
}
function f(uint y) internal view returns (uint) {
assert(y > 0);
assert(x == 0);
return y;
}
}
// ----
// Warning: (162-175): Assertion violation happens here
// Warning: (179-193): Assertion violation happens here
@@ -15,7 +15,7 @@ contract A {
// 2 warnings, B.f and A.g
contract B is A {
function f() public view {
assert(x == 0);
assert(x == 1);
}
}
// ----
@@ -17,7 +17,7 @@ contract B is A {
uint y;
function f() public view {
assert(x == 0);
assert(x == 1);
}
}
// ----
@@ -17,10 +17,10 @@ contract B is A {
uint y;
function f() public view {
assert(x == 0);
assert(x == 1);
}
function h() public view {
assert(x == 2);
assert(x == 1);
}
}
@@ -29,10 +29,10 @@ contract C is B {
uint z;
function f() public view {
assert(x == 0);
assert(x == 1);
}
function i() public view {
assert(x == 0);
assert(x == 1);
}
}
// ----
@@ -0,0 +1,16 @@
pragma experimental SMTChecker;
contract A {
uint x;
constructor (uint y) public { assert(x == 0); x = y; }
}
contract B is A {
constructor () A(2) public { assert(x == 2); }
}
contract C is B {
function f() public view {
assert(x == 2);
}
}
@@ -0,0 +1,20 @@
pragma experimental SMTChecker;
contract A {
uint x;
function h() public view {
assert(x == 0);
}
}
contract B is A {
function g() public view {
assert(x == 0);
}
}
contract C is B {
function f() public view {
assert(x == 0);
}
}