Merge pull request #9661 from ethereum/smtBitwiseOr

[SMTChecker] Support bitwise or, xor and not operator
This commit is contained in:
Leonardo
2020-08-26 18:20:15 +02:00
committed by GitHub
18 changed files with 203 additions and 22 deletions
@@ -0,0 +1,12 @@
pragma experimental SMTChecker;
contract C {
function f() public pure {
uint8 x = 0xff;
uint8 y = ~x;
assert(x & y == 0);
assert(x | y == 0xff);
assert(x ^ y == 0xff);
}
}
// ----
@@ -0,0 +1,8 @@
pragma experimental SMTChecker;
contract C {
function f() public pure returns (byte) {
return (~byte(0xFF));
}
}
// ----
// Warning 5084: (102-112): Type conversion is not yet fully supported and might yield false positives.
@@ -0,0 +1,21 @@
pragma experimental SMTChecker;
contract C {
function f() public pure {
int16 x = 1;
assert(~x == 0);
x = 0xff;
assert(~x == 0);
x = 0x0f;
assert(~x == 0xf0);
x = -1;
assert(~x != 0);
x = -2;
assert(~x == 1);
}
}
// ----
// Warning 6328: (91-106): Assertion violation happens here
// Warning 6328: (122-137): Assertion violation happens here
// Warning 6328: (153-171): Assertion violation happens here
// Warning 6328: (185-200): Assertion violation happens here
@@ -0,0 +1,15 @@
pragma experimental SMTChecker;
contract C {
function f() public pure {
uint8 x = 0xff;
assert(~x == 0x00);
uint16 y = 0xff00;
assert(~y == 0xff);
assert(~y == 0xffff);
assert(~y == 0x0000);
}
}
// ----
// Warning 6328: (159-179): Assertion violation happens here
// Warning 6328: (183-203): Assertion violation happens here
@@ -0,0 +1,9 @@
pragma experimental SMTChecker;
contract C {
function f() public pure returns (byte) {
return (byte(0x0F) | (byte(0xF0)));
}
}
// ----
// Warning 5084: (101-111): Type conversion is not yet fully supported and might yield false positives.
// Warning 5084: (115-125): Type conversion is not yet fully supported and might yield false positives.
@@ -0,0 +1,21 @@
pragma experimental SMTChecker;
contract C {
function f() public pure {
int16 x = 1;
int16 y = 0;
assert(x | y == 1);
x = 0; y = 0;
assert(x | y != 0);
y = 240;
x = 15;
int16 z = x | y;
assert(z == 255);
x = -1; y = 200;
assert(x | y == x);
assert(x | z != -1);
}
}
// ----
// Warning 6328: (144-162): Assertion violation happens here
// Warning 6328: (267-286): Assertion violation happens here
@@ -0,0 +1,17 @@
pragma experimental SMTChecker;
contract C {
function f() public pure {
uint8 x = 1;
uint16 y = 0;
assert(x | y != 0);
x = 0xff;
y = 0xff00;
assert(x | y == 0xff);
assert(x | y == 0xffff);
assert(x | y == 0x0000);
}
}
// ----
// Warning 6328: (155-176): Assertion violation happens here
// Warning 6328: (207-230): Assertion violation happens here
@@ -6,4 +6,3 @@ contract Simp {
}
}
// ----
// Warning 1093: (142-152): Assertion checker does not yet implement this bitwise operator.
@@ -0,0 +1,19 @@
pragma experimental SMTChecker;
contract C {
function f() public pure {
int8 x = 1;
int16 y = 0;
assert(x ^ y == 1);
int16 z = -1;
assert(x ^ z == -2);
assert(y ^ z == -1);
assert(y ^ z > 0);
x = 7; y = 3;
assert(x ^ y < 5);
assert(x ^ y > 5);
}
}
// ----
// Warning 6328: (189-206): Assertion violation happens here
// Warning 6328: (247-264): Assertion violation happens here
@@ -0,0 +1,17 @@
pragma experimental SMTChecker;
contract C {
function f() public pure {
uint8 x = 1;
uint16 y = 0;
assert(x ^ y != 0);
x = 0xff;
y = 0xff00;
assert(x ^ y == 0xff);
assert(x ^ y == 0xffff);
assert(x ^ y == 0x0000);
}
}
// ----
// Warning 6328: (155-176): Assertion violation happens here
// Warning 6328: (207-230): Assertion violation happens here