mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Merge remote-tracking branch 'origin/develop' into breaking
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
contract test {
|
||||
uint value1;
|
||||
uint value2;
|
||||
function f(uint x, uint y) public returns (uint w) {
|
||||
uint value3 = y;
|
||||
value1 += x;
|
||||
value3 *= x;
|
||||
value2 *= value3 + value1;
|
||||
return value2 += 7;
|
||||
}
|
||||
}
|
||||
// ====
|
||||
// compileViaYul: also
|
||||
// ----
|
||||
// f(uint256,uint256): 0, 6 -> 7
|
||||
// f(uint256,uint256): 1, 3 -> 0x23
|
||||
// f(uint256,uint256): 2, 25 -> 0x0746
|
||||
// f(uint256,uint256): 3, 69 -> 396613
|
||||
// f(uint256,uint256): 4, 84 -> 137228105
|
||||
// f(uint256,uint256): 5, 2 -> 0xcc7c5e28
|
||||
// f(uint256,uint256): 6, 51 -> 1121839760671
|
||||
// f(uint256,uint256): 7, 48 -> 408349672884251
|
||||
@@ -0,0 +1,34 @@
|
||||
contract C {
|
||||
function shl(uint256 a, uint256 b) public returns (uint256 c) {
|
||||
assembly {
|
||||
c := shl(b, a)
|
||||
}
|
||||
}
|
||||
|
||||
function shr(uint256 a, uint256 b) public returns (uint256 c) {
|
||||
assembly {
|
||||
c := shr(b, a)
|
||||
}
|
||||
}
|
||||
|
||||
function sar(uint256 a, uint256 b) public returns (uint256 c) {
|
||||
assembly {
|
||||
c := sar(b, a)
|
||||
}
|
||||
}
|
||||
}
|
||||
// ====
|
||||
// EVMVersion: >=constantinople
|
||||
// compileViaYul: also
|
||||
// ----
|
||||
// shl(uint256,uint256): 0x01, 0x02 -> 0x04
|
||||
// shl(uint256,uint256): 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff, 0x01 -> 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe
|
||||
// shl(uint256,uint256): 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff, 0x100 -> 0x00
|
||||
// shr(uint256,uint256): 0x03, 0x01 -> 0x01
|
||||
// shr(uint256,uint256): 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff, 0x01 -> 0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
|
||||
// shr(uint256,uint256): 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff, 0xff -> 0x01
|
||||
// shr(uint256,uint256): 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff, 0x100 -> 0x00
|
||||
// sar(uint256,uint256): 0x03, 0x01 -> 0x01
|
||||
// sar(uint256,uint256): 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff, 0x01 -> 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
|
||||
// sar(uint256,uint256): 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff, 0xff -> 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
|
||||
// sar(uint256,uint256): 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff, 0x100 -> 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
|
||||
+122
@@ -0,0 +1,122 @@
|
||||
contract C {
|
||||
function shl_zero(uint256 a) public returns (uint256 c) {
|
||||
assembly {
|
||||
c := shl(0, a)
|
||||
}
|
||||
}
|
||||
|
||||
function shr_zero(uint256 a) public returns (uint256 c) {
|
||||
assembly {
|
||||
c := shr(0, a)
|
||||
}
|
||||
}
|
||||
|
||||
function sar_zero(uint256 a) public returns (uint256 c) {
|
||||
assembly {
|
||||
c := sar(0, a)
|
||||
}
|
||||
}
|
||||
|
||||
function shl_large(uint256 a) public returns (uint256 c) {
|
||||
assembly {
|
||||
c := shl(0x110, a)
|
||||
}
|
||||
}
|
||||
|
||||
function shr_large(uint256 a) public returns (uint256 c) {
|
||||
assembly {
|
||||
c := shr(0x110, a)
|
||||
}
|
||||
}
|
||||
|
||||
function sar_large(uint256 a) public returns (uint256 c) {
|
||||
assembly {
|
||||
c := sar(0x110, a)
|
||||
}
|
||||
}
|
||||
|
||||
function shl_combined(uint256 a) public returns (uint256 c) {
|
||||
assembly {
|
||||
c := shl(4, shl(12, a))
|
||||
}
|
||||
}
|
||||
|
||||
function shr_combined(uint256 a) public returns (uint256 c) {
|
||||
assembly {
|
||||
c := shr(4, shr(12, a))
|
||||
}
|
||||
}
|
||||
|
||||
function sar_combined(uint256 a) public returns (uint256 c) {
|
||||
assembly {
|
||||
c := sar(4, sar(12, a))
|
||||
}
|
||||
}
|
||||
|
||||
function shl_combined_large(uint256 a) public returns (uint256 c) {
|
||||
assembly {
|
||||
c := shl(0xd0, shl(0x40, a))
|
||||
}
|
||||
}
|
||||
|
||||
function shl_combined_overflow(uint256 a) public returns (uint256 c) {
|
||||
assembly {
|
||||
c := shl(0x01, shl(not(0x00), a))
|
||||
}
|
||||
}
|
||||
|
||||
function shr_combined_large(uint256 a) public returns (uint256 c) {
|
||||
assembly {
|
||||
c := shr(0xd0, shr(0x40, a))
|
||||
}
|
||||
}
|
||||
|
||||
function shr_combined_overflow(uint256 a) public returns (uint256 c) {
|
||||
assembly {
|
||||
c := shr(0x01, shr(not(0x00), a))
|
||||
}
|
||||
}
|
||||
|
||||
function sar_combined_large(uint256 a) public returns (uint256 c) {
|
||||
assembly {
|
||||
c := sar(0xd0, sar(0x40, a))
|
||||
}
|
||||
}
|
||||
}
|
||||
// ====
|
||||
// EVMVersion: >=constantinople
|
||||
// compileViaYul: also
|
||||
// ----
|
||||
// shl_zero(uint256): 0x00 -> 0x00
|
||||
// shl_zero(uint256): 0xffff -> 0xffff
|
||||
// shl_zero(uint256): 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff -> 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
|
||||
// shr_zero(uint256): 0x00 -> 0x00
|
||||
// shr_zero(uint256): 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff -> 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
|
||||
// sar_zero(uint256): 0x00 -> 0x00
|
||||
// sar_zero(uint256): 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff -> 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
|
||||
// shl_large(uint256): 0x00 -> 0x00
|
||||
// shl_large(uint256): 0xffff -> 0x00
|
||||
// shl_large(uint256): 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff -> 0x00
|
||||
// shr_large(uint256): 0x00 -> 0x00
|
||||
// shr_large(uint256): 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff -> 0x00
|
||||
// sar_large(uint256): 0x00 -> 0x00
|
||||
// sar_large(uint256): 0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff -> 0x00
|
||||
// sar_large(uint256): 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff -> 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
|
||||
// shl_combined(uint256): 0x00 -> 0x00
|
||||
// shl_combined(uint256): 0xffff -> 0xffff0000
|
||||
// shl_combined(uint256): 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff -> 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0000
|
||||
// shr_combined(uint256): 0x00 -> 0x00
|
||||
// shr_combined(uint256): 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff -> 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
|
||||
// sar_combined(uint256): 0x00 -> 0x00
|
||||
// sar_combined(uint256): 0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff -> 0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
|
||||
// sar_combined(uint256): 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff -> 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
|
||||
// shl_combined_large(uint256): 0x00 -> 0x00
|
||||
// shl_combined_large(uint256): 0xffff -> 0x00
|
||||
// shl_combined_large(uint256): 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff -> 0x00
|
||||
// shl_combined_overflow(uint256): 0x02 -> 0x00
|
||||
// shr_combined_large(uint256): 0x00 -> 0x00
|
||||
// shr_combined_large(uint256): 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff -> 0x00
|
||||
// shr_combined_overflow(uint256): 0x02 -> 0x00
|
||||
// sar_combined_large(uint256): 0x00 -> 0x00
|
||||
// sar_combined_large(uint256): 0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff -> 0x00
|
||||
// sar_combined_large(uint256): 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff -> 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
|
||||
+83
@@ -0,0 +1,83 @@
|
||||
contract C {
|
||||
function shl_1() public returns (bool) {
|
||||
uint256 c;
|
||||
assembly {
|
||||
c := shl(2, 1)
|
||||
}
|
||||
assert(c == 4);
|
||||
return true;
|
||||
}
|
||||
|
||||
function shl_2() public returns (bool) {
|
||||
uint256 c;
|
||||
assembly {
|
||||
c := shl(
|
||||
1,
|
||||
0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
|
||||
)
|
||||
}
|
||||
assert(
|
||||
c ==
|
||||
0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe
|
||||
);
|
||||
return true;
|
||||
}
|
||||
|
||||
function shl_3() public returns (bool) {
|
||||
uint256 c;
|
||||
assembly {
|
||||
c := shl(
|
||||
256,
|
||||
0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
|
||||
)
|
||||
}
|
||||
assert(c == 0);
|
||||
return true;
|
||||
}
|
||||
|
||||
function shr_1() public returns (bool) {
|
||||
uint256 c;
|
||||
assembly {
|
||||
c := shr(1, 3)
|
||||
}
|
||||
assert(c == 1);
|
||||
return true;
|
||||
}
|
||||
|
||||
function shr_2() public returns (bool) {
|
||||
uint256 c;
|
||||
assembly {
|
||||
c := shr(
|
||||
1,
|
||||
0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
|
||||
)
|
||||
}
|
||||
assert(
|
||||
c ==
|
||||
0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
|
||||
);
|
||||
return true;
|
||||
}
|
||||
|
||||
function shr_3() public returns (bool) {
|
||||
uint256 c;
|
||||
assembly {
|
||||
c := shr(
|
||||
256,
|
||||
0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
|
||||
)
|
||||
}
|
||||
assert(c == 0);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
// ====
|
||||
// EVMVersion: >=constantinople
|
||||
// compileViaYul: also
|
||||
// ----
|
||||
// shl_1() -> 0x01
|
||||
// shl_2() -> 0x01
|
||||
// shl_3() -> 0x01
|
||||
// shr_1() -> 0x01
|
||||
// shr_2() -> 0x01
|
||||
// shr_3() -> 0x01
|
||||
@@ -0,0 +1,15 @@
|
||||
contract C {
|
||||
function f() public returns (uint16 x) {
|
||||
unchecked {
|
||||
x = 0xffff;
|
||||
x += 32;
|
||||
x <<= 8;
|
||||
x >>= 16;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ====
|
||||
// compileViaYul: also
|
||||
// ----
|
||||
// f() -> 0x0
|
||||
@@ -0,0 +1,13 @@
|
||||
contract C {
|
||||
function f() public returns (uint8 x) {
|
||||
assembly {
|
||||
x := 0xffff
|
||||
}
|
||||
x >>= 8;
|
||||
}
|
||||
}
|
||||
|
||||
// ====
|
||||
// compileViaYul: also
|
||||
// ----
|
||||
// f() -> 0x0
|
||||
@@ -0,0 +1,7 @@
|
||||
contract C {
|
||||
uint256 public a = 0x42 << 8;
|
||||
}
|
||||
// ====
|
||||
// compileViaYul: also
|
||||
// ----
|
||||
// a() -> 0x4200
|
||||
@@ -0,0 +1,11 @@
|
||||
contract C {
|
||||
function f() public returns (uint256 a) {
|
||||
a = 0x42;
|
||||
a <<= 8;
|
||||
}
|
||||
}
|
||||
|
||||
// ====
|
||||
// compileViaYul: also
|
||||
// ----
|
||||
// f() -> 0x4200
|
||||
@@ -0,0 +1,7 @@
|
||||
contract C {
|
||||
uint256 public a = 0x4200 >> 8;
|
||||
}
|
||||
// ====
|
||||
// compileViaYul: also
|
||||
// ----
|
||||
// a() -> 0x42
|
||||
@@ -0,0 +1,11 @@
|
||||
contract C {
|
||||
function f() public returns (uint256 a) {
|
||||
a = 0x4200;
|
||||
a >>= 8;
|
||||
}
|
||||
}
|
||||
|
||||
// ====
|
||||
// compileViaYul: also
|
||||
// ----
|
||||
// f() -> 0x42
|
||||
@@ -0,0 +1,15 @@
|
||||
contract C {
|
||||
function f(uint256 a, uint256 b) public returns (uint256) {
|
||||
return a << b;
|
||||
}
|
||||
}
|
||||
|
||||
// ====
|
||||
// compileViaYul: also
|
||||
// ----
|
||||
// f(uint256,uint256): 0x4266, 0x0 -> 0x4266
|
||||
// f(uint256,uint256): 0x4266, 0x8 -> 0x426600
|
||||
// f(uint256,uint256): 0x4266, 0x10 -> 0x42660000
|
||||
// f(uint256,uint256): 0x4266, 0x11 -> 0x84cc0000
|
||||
// f(uint256,uint256): 0x4266, 0xf0 -> 0x4266000000000000000000000000000000000000000000000000000000000000
|
||||
// f(uint256,uint256): 0x4266, 0x100 -> 0
|
||||
@@ -0,0 +1,16 @@
|
||||
contract C {
|
||||
function f(uint256 a, uint256 b) public returns (uint256) {
|
||||
a <<= b;
|
||||
return a;
|
||||
}
|
||||
}
|
||||
|
||||
// ====
|
||||
// compileViaYul: also
|
||||
// ----
|
||||
// f(uint256,uint256): 0x4266, 0x0 -> 0x4266
|
||||
// f(uint256,uint256): 0x4266, 0x8 -> 0x426600
|
||||
// f(uint256,uint256): 0x4266, 0x10 -> 0x42660000
|
||||
// f(uint256,uint256): 0x4266, 0x11 -> 0x84cc0000
|
||||
// f(uint256,uint256): 0x4266, 0xf0 -> 0x4266000000000000000000000000000000000000000000000000000000000000
|
||||
// f(uint256,uint256): 0x4266, 0x100 -> 0
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
contract C {
|
||||
function f(uint256 a, uint8 b) public returns (uint256) {
|
||||
a <<= b;
|
||||
return a;
|
||||
}
|
||||
}
|
||||
|
||||
// ====
|
||||
// compileViaYul: also
|
||||
// ----
|
||||
// f(uint256,uint8): 0x4266, 0x0 -> 0x4266
|
||||
// f(uint256,uint8): 0x4266, 0x8 -> 0x426600
|
||||
// f(uint256,uint8): 0x4266, 0x10 -> 0x42660000
|
||||
// f(uint256,uint8): 0x4266, 0x11 -> 0x84cc0000
|
||||
// f(uint256,uint8): 0x4266, 0xf0 -> 0x4266000000000000000000000000000000000000000000000000000000000000
|
||||
@@ -0,0 +1,12 @@
|
||||
// This basically tests proper cleanup and conversion. It should not convert x to int8.
|
||||
contract C {
|
||||
function f() public returns (int8) {
|
||||
uint8 x = 254;
|
||||
int8 y = 1;
|
||||
return y << x;
|
||||
}
|
||||
}
|
||||
// ====
|
||||
// compileViaYul: also
|
||||
// ----
|
||||
// f() -> 0
|
||||
@@ -0,0 +1,14 @@
|
||||
contract C {
|
||||
function f(uint32 a, uint32 b) public returns (uint256) {
|
||||
return a << b;
|
||||
}
|
||||
}
|
||||
|
||||
// ====
|
||||
// compileViaYul: also
|
||||
// ----
|
||||
// f(uint32,uint32): 0x4266, 0x0 -> 0x4266
|
||||
// f(uint32,uint32): 0x4266, 0x8 -> 0x426600
|
||||
// f(uint32,uint32): 0x4266, 0x10 -> 0x42660000
|
||||
// f(uint32,uint32): 0x4266, 0x11 -> 0x84cc0000
|
||||
// f(uint32,uint32): 0x4266, 0x20 -> 0
|
||||
@@ -0,0 +1,11 @@
|
||||
contract C {
|
||||
function f(uint8 a, uint8 b) public returns (uint256) {
|
||||
return a << b;
|
||||
}
|
||||
}
|
||||
|
||||
// ====
|
||||
// compileViaYul: also
|
||||
// ----
|
||||
// f(uint8,uint8): 0x66, 0x0 -> 0x66
|
||||
// f(uint8,uint8): 0x66, 0x8 -> 0
|
||||
@@ -0,0 +1,7 @@
|
||||
contract C {
|
||||
int256 public a = -0x42 << 8;
|
||||
}
|
||||
// ====
|
||||
// compileViaYul: also
|
||||
// ----
|
||||
// a() -> -16896
|
||||
@@ -0,0 +1,7 @@
|
||||
contract C {
|
||||
int256 public a = -0x4200 >> 8;
|
||||
}
|
||||
// ====
|
||||
// compileViaYul: also
|
||||
// ----
|
||||
// a() -> -66
|
||||
@@ -0,0 +1,18 @@
|
||||
contract C {
|
||||
function leftU(uint8 x, uint8 y) public returns (uint8) {
|
||||
return x << y;
|
||||
}
|
||||
|
||||
function leftS(int8 x, uint8 y) public returns (int8) {
|
||||
return x << y;
|
||||
}
|
||||
}
|
||||
|
||||
// ====
|
||||
// compileViaYul: also
|
||||
// ----
|
||||
// leftU(uint8,uint8): 255, 8 -> 0
|
||||
// leftU(uint8,uint8): 255, 1 -> 254
|
||||
// leftU(uint8,uint8): 255, 0 -> 255
|
||||
// leftS(int8,uint8): 1, 7 -> -128 # Result is -128 and output is sign-extended, not zero-padded. #
|
||||
// leftS(int8,uint8): 1, 6 -> 64
|
||||
@@ -0,0 +1,14 @@
|
||||
contract C {
|
||||
function f(uint256 a, uint256 b) public returns (uint256) {
|
||||
return a >> b;
|
||||
}
|
||||
}
|
||||
|
||||
// ====
|
||||
// compileViaYul: also
|
||||
// ----
|
||||
// f(uint256,uint256): 0x4266, 0x0 -> 0x4266
|
||||
// f(uint256,uint256): 0x4266, 0x8 -> 0x42
|
||||
// f(uint256,uint256): 0x4266, 0x10 -> 0
|
||||
// f(uint256,uint256): 0x4266, 0x11 -> 0
|
||||
// f(uint256,uint256): 57896044618658097711785492504343953926634992332820282019728792003956564819968, 5 -> 1809251394333065553493296640760748560207343510400633813116524750123642650624
|
||||
@@ -0,0 +1,14 @@
|
||||
contract C {
|
||||
function f(uint256 a, uint256 b) public returns (uint256) {
|
||||
a >>= b;
|
||||
return a;
|
||||
}
|
||||
}
|
||||
|
||||
// ====
|
||||
// compileViaYul: also
|
||||
// ----
|
||||
// f(uint256,uint256): 0x4266, 0x0 -> 0x4266
|
||||
// f(uint256,uint256): 0x4266, 0x8 -> 0x42
|
||||
// f(uint256,uint256): 0x4266, 0x10 -> 0
|
||||
// f(uint256,uint256): 0x4266, 0x11 -> 0
|
||||
@@ -0,0 +1,14 @@
|
||||
contract C {
|
||||
function f(uint8 a, uint8 b) public returns (uint256) {
|
||||
assembly {
|
||||
a := 0xffffffff
|
||||
}
|
||||
// Higher bits should be cleared before the shift
|
||||
return a >> b;
|
||||
}
|
||||
}
|
||||
// ====
|
||||
// ABIEncoderV1Only: true
|
||||
// ----
|
||||
// f(uint8,uint8): 0x00, 0x04 -> 0x0f
|
||||
// f(uint8,uint8): 0x00, 0x1004 -> 0x0f
|
||||
@@ -0,0 +1,30 @@
|
||||
contract C {
|
||||
function f(int8 a, uint8 b) public returns (int256) {
|
||||
assembly {
|
||||
a := 0xfffffff0
|
||||
}
|
||||
// Higher bits should be signextended before the shift
|
||||
return a >> b;
|
||||
}
|
||||
|
||||
function g(int8 a, uint8 b) public returns (int256) {
|
||||
assembly {
|
||||
a := 0xf0
|
||||
}
|
||||
// Higher bits should be signextended before the shift
|
||||
return a >> b;
|
||||
}
|
||||
}
|
||||
// ====
|
||||
// ABIEncoderV1Only: true
|
||||
// ----
|
||||
// f(int8,uint8): 0x00, 0x03 -> 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe
|
||||
// f(int8,uint8): 0x00, 0x04 -> 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
|
||||
// f(int8,uint8): 0x00, 0xff -> 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
|
||||
// f(int8,uint8): 0x00, 0x1003 -> 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe
|
||||
// f(int8,uint8): 0x00, 0x1004 -> 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
|
||||
// g(int8,uint8): 0x00, 0x03 -> 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe
|
||||
// g(int8,uint8): 0x00, 0x04 -> 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
|
||||
// g(int8,uint8): 0x00, 0xff -> 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
|
||||
// g(int8,uint8): 0x00, 0x1003 -> 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe
|
||||
// g(int8,uint8): 0x00, 0x1004 -> 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
|
||||
@@ -0,0 +1,33 @@
|
||||
pragma experimental ABIEncoderV2;
|
||||
|
||||
|
||||
contract C {
|
||||
function f(int8 a, uint8 b) public returns (int256) {
|
||||
assembly {
|
||||
a := 0xfffffff0
|
||||
}
|
||||
// Higher bits should be signextended before the shift
|
||||
return a >> b;
|
||||
}
|
||||
|
||||
function g(int8 a, uint8 b) public returns (int256) {
|
||||
assembly {
|
||||
a := 0xf0
|
||||
}
|
||||
// Higher bits should be signextended before the shift
|
||||
return a >> b;
|
||||
}
|
||||
}
|
||||
// ====
|
||||
// compileViaYul: also
|
||||
// ----
|
||||
// f(int8,uint8): 0x00, 0x03 -> 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe
|
||||
// f(int8,uint8): 0x00, 0x04 -> 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
|
||||
// f(int8,uint8): 0x00, 0xff -> 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
|
||||
// f(int8,uint8): 0x00, 0x1003 -> FAILURE
|
||||
// f(int8,uint8): 0x00, 0x1004 -> FAILURE
|
||||
// g(int8,uint8): 0x00, 0x03 -> 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe
|
||||
// g(int8,uint8): 0x00, 0x04 -> 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
|
||||
// g(int8,uint8): 0x00, 0xff -> 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
|
||||
// g(int8,uint8): 0x00, 0x1003 -> FAILURE
|
||||
// g(int8,uint8): 0x00, 0x1004 -> FAILURE
|
||||
@@ -0,0 +1,17 @@
|
||||
pragma experimental ABIEncoderV2;
|
||||
|
||||
|
||||
contract C {
|
||||
function f(uint8 a, uint8 b) public returns (uint256) {
|
||||
assembly {
|
||||
a := 0xffffffff
|
||||
}
|
||||
// Higher bits should be cleared before the shift
|
||||
return a >> b;
|
||||
}
|
||||
}
|
||||
// ====
|
||||
// compileViaYul: also
|
||||
// ----
|
||||
// f(uint8,uint8): 0x00, 0x04 -> 0x0f
|
||||
// f(uint8,uint8): 0x00, 0x1004 -> FAILURE
|
||||
@@ -0,0 +1,65 @@
|
||||
contract C {
|
||||
function f1() public pure returns (bool) {
|
||||
return (-4266 >> 0) == -4266;
|
||||
}
|
||||
|
||||
function f2() public pure returns (bool) {
|
||||
return (-4266 >> 1) == -2133;
|
||||
}
|
||||
|
||||
function f3() public pure returns (bool) {
|
||||
return (-4266 >> 4) == -267;
|
||||
}
|
||||
|
||||
function f4() public pure returns (bool) {
|
||||
return (-4266 >> 8) == -17;
|
||||
}
|
||||
|
||||
function f5() public pure returns (bool) {
|
||||
return (-4266 >> 16) == -1;
|
||||
}
|
||||
|
||||
function f6() public pure returns (bool) {
|
||||
return (-4266 >> 17) == -1;
|
||||
}
|
||||
|
||||
function g1() public pure returns (bool) {
|
||||
return (-4267 >> 0) == -4267;
|
||||
}
|
||||
|
||||
function g2() public pure returns (bool) {
|
||||
return (-4267 >> 1) == -2134;
|
||||
}
|
||||
|
||||
function g3() public pure returns (bool) {
|
||||
return (-4267 >> 4) == -267;
|
||||
}
|
||||
|
||||
function g4() public pure returns (bool) {
|
||||
return (-4267 >> 8) == -17;
|
||||
}
|
||||
|
||||
function g5() public pure returns (bool) {
|
||||
return (-4267 >> 16) == -1;
|
||||
}
|
||||
|
||||
function g6() public pure returns (bool) {
|
||||
return (-4267 >> 17) == -1;
|
||||
}
|
||||
}
|
||||
|
||||
// ====
|
||||
// compileViaYul: also
|
||||
// ----
|
||||
// f1() -> true
|
||||
// f2() -> true
|
||||
// f3() -> true
|
||||
// f4() -> true
|
||||
// f5() -> true
|
||||
// f6() -> true
|
||||
// g1() -> true
|
||||
// g2() -> true
|
||||
// g3() -> true
|
||||
// g4() -> true
|
||||
// g5() -> true
|
||||
// g6() -> true
|
||||
@@ -0,0 +1,21 @@
|
||||
contract C {
|
||||
function f(int256 a, uint256 b) public returns (int256) {
|
||||
return a >> b;
|
||||
}
|
||||
}
|
||||
|
||||
// ====
|
||||
// compileViaYul: also
|
||||
// ----
|
||||
// f(int256,uint256): -4266, 0 -> -4266
|
||||
// f(int256,uint256): -4266, 1 -> -2133
|
||||
// f(int256,uint256): -4266, 4 -> -267
|
||||
// f(int256,uint256): -4266, 8 -> -17
|
||||
// f(int256,uint256): -4266, 16 -> -1
|
||||
// f(int256,uint256): -4266, 17 -> -1
|
||||
// f(int256,uint256): -4267, 0 -> -4267
|
||||
// f(int256,uint256): -4267, 1 -> -2134
|
||||
// f(int256,uint256): -4267, 4 -> -267
|
||||
// f(int256,uint256): -4267, 8 -> -17
|
||||
// f(int256,uint256): -4267, 16 -> -1
|
||||
// f(int256,uint256): -4267, 17 -> -1
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
contract C {
|
||||
function f(int256 a, uint256 b) public returns (int256) {
|
||||
a >>= b;
|
||||
return a;
|
||||
}
|
||||
}
|
||||
|
||||
// ====
|
||||
// compileViaYul: also
|
||||
// ----
|
||||
// f(int256,uint256): -4266, 0 -> -4266
|
||||
// f(int256,uint256): -4266, 1 -> -2133
|
||||
// f(int256,uint256): -4266, 4 -> -267
|
||||
// f(int256,uint256): -4266, 8 -> -17
|
||||
// f(int256,uint256): -4266, 16 -> -1
|
||||
// f(int256,uint256): -4266, 17 -> -1
|
||||
// f(int256,uint256): -4267, 0 -> -4267
|
||||
// f(int256,uint256): -4267, 1 -> -2134
|
||||
// f(int256,uint256): -4267, 4 -> -267
|
||||
// f(int256,uint256): -4267, 8 -> -17
|
||||
// f(int256,uint256): -4267, 16 -> -1
|
||||
// f(int256,uint256): -4267, 17 -> -1
|
||||
@@ -0,0 +1,21 @@
|
||||
contract C {
|
||||
function f(int16 a, uint16 b) public returns (int256) {
|
||||
return a >> b;
|
||||
}
|
||||
}
|
||||
|
||||
// ====
|
||||
// compileViaYul: also
|
||||
// ----
|
||||
// f(int16,uint16): -4266, 0 -> -4266
|
||||
// f(int16,uint16): -4266, 1 -> -2133
|
||||
// f(int16,uint16): -4266, 4 -> -267
|
||||
// f(int16,uint16): -4266, 8 -> -17
|
||||
// f(int16,uint16): -4266, 16 -> -1
|
||||
// f(int16,uint16): -4266, 17 -> -1
|
||||
// f(int16,uint16): -4267, 0 -> -4267
|
||||
// f(int16,uint16): -4267, 1 -> -2134
|
||||
// f(int16,uint16): -4267, 4 -> -267
|
||||
// f(int16,uint16): -4267, 8 -> -17
|
||||
// f(int16,uint16): -4267, 16 -> -1
|
||||
// f(int16,uint16): -4267, 17 -> -1
|
||||
@@ -0,0 +1,21 @@
|
||||
contract C {
|
||||
function f(int32 a, uint32 b) public returns (int256) {
|
||||
return a >> b;
|
||||
}
|
||||
}
|
||||
|
||||
// ====
|
||||
// compileViaYul: also
|
||||
// ----
|
||||
// f(int32,uint32): -4266, 0 -> -4266
|
||||
// f(int32,uint32): -4266, 1 -> -2133
|
||||
// f(int32,uint32): -4266, 4 -> -267
|
||||
// f(int32,uint32): -4266, 8 -> -17
|
||||
// f(int32,uint32): -4266, 16 -> -1
|
||||
// f(int32,uint32): -4266, 17 -> -1
|
||||
// f(int32,uint32): -4267, 0 -> -4267
|
||||
// f(int32,uint32): -4267, 1 -> -2134
|
||||
// f(int32,uint32): -4267, 4 -> -267
|
||||
// f(int32,uint32): -4267, 8 -> -17
|
||||
// f(int32,uint32): -4267, 16 -> -1
|
||||
// f(int32,uint32): -4267, 17 -> -1
|
||||
@@ -0,0 +1,21 @@
|
||||
contract C {
|
||||
function f(int8 a, uint8 b) public returns (int256) {
|
||||
return a >> b;
|
||||
}
|
||||
}
|
||||
|
||||
// ====
|
||||
// compileViaYul: also
|
||||
// ----
|
||||
// f(int8,uint8): -66, 0 -> -66
|
||||
// f(int8,uint8): -66, 1 -> -33
|
||||
// f(int8,uint8): -66, 4 -> -5
|
||||
// f(int8,uint8): -66, 8 -> -1
|
||||
// f(int8,uint8): -66, 16 -> -1
|
||||
// f(int8,uint8): -66, 17 -> -1
|
||||
// f(int8,uint8): -67, 0 -> -67
|
||||
// f(int8,uint8): -67, 1 -> -34
|
||||
// f(int8,uint8): -67, 4 -> -5
|
||||
// f(int8,uint8): -67, 8 -> -1
|
||||
// f(int8,uint8): -67, 16 -> -1
|
||||
// f(int8,uint8): -67, 17 -> -1
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
contract C {
|
||||
function f(int16 a, uint16 b) public returns (int16) {
|
||||
return a >> b;
|
||||
}
|
||||
}
|
||||
// ====
|
||||
// ABIEncoderV1Only: true
|
||||
// ----
|
||||
// f(int16,uint16): 0xff99, 0x00 -> 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff99
|
||||
// f(int16,uint16): 0xff99, 0x01 -> 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffcc
|
||||
// f(int16,uint16): 0xff99, 0x02 -> 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe6
|
||||
// f(int16,uint16): 0xff99, 0x04 -> 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff9
|
||||
// f(int16,uint16): 0xff99, 0x08 -> 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
pragma experimental ABIEncoderV2;
|
||||
|
||||
|
||||
contract C {
|
||||
function f(int16 a, uint16 b) public returns (int16) {
|
||||
return a >> b;
|
||||
}
|
||||
}
|
||||
// ====
|
||||
// compileViaYul: also
|
||||
// ----
|
||||
// f(int16,uint16): 0xff99, 0x00 -> FAILURE
|
||||
// f(int16,uint16): 0xff99, 0x01 -> FAILURE
|
||||
// f(int16,uint16): 0xff99, 0x02 -> FAILURE
|
||||
// f(int16,uint16): 0xff99, 0x04 -> FAILURE
|
||||
// f(int16,uint16): 0xff99, 0x08 -> FAILURE
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
contract C {
|
||||
function f(int32 a, uint32 b) public returns (int32) {
|
||||
return a >> b;
|
||||
}
|
||||
}
|
||||
// ====
|
||||
// ABIEncoderV1Only: true
|
||||
// ----
|
||||
// f(int32,uint32): 0xffffff99, 0x00 -> 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff99
|
||||
// f(int32,uint32): 0xffffff99, 0x01 -> 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffcc
|
||||
// f(int32,uint32): 0xffffff99, 0x02 -> 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe6
|
||||
// f(int32,uint32): 0xffffff99, 0x04 -> 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff9
|
||||
// f(int32,uint32): 0xffffff99, 0x08 -> 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
pragma experimental ABIEncoderV2;
|
||||
|
||||
|
||||
contract C {
|
||||
function f(int32 a, uint32 b) public returns (int32) {
|
||||
return a >> b;
|
||||
}
|
||||
}
|
||||
// ====
|
||||
// compileViaYul: also
|
||||
// ----
|
||||
// f(int32,uint32): 0xffffff99, 0x00 -> FAILURE
|
||||
// f(int32,uint32): 0xffffff99, 0x01 -> FAILURE
|
||||
// f(int32,uint32): 0xffffff99, 0x02 -> FAILURE
|
||||
// f(int32,uint32): 0xffffff99, 0x04 -> FAILURE
|
||||
// f(int32,uint32): 0xffffff99, 0x08 -> FAILURE
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
contract C {
|
||||
function f(int8 a, uint8 b) public returns (int8) {
|
||||
return a >> b;
|
||||
}
|
||||
}
|
||||
// ====
|
||||
// ABIEncoderV1Only: true
|
||||
// ----
|
||||
// f(int8,uint8): 0x99, 0x00 -> 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff99
|
||||
// f(int8,uint8): 0x99, 0x01 -> 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffcc
|
||||
// f(int8,uint8): 0x99, 0x02 -> 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe6
|
||||
// f(int8,uint8): 0x99, 0x04 -> 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff9
|
||||
// f(int8,uint8): 0x99, 0x08 -> 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
pragma experimental ABIEncoderV2;
|
||||
|
||||
|
||||
contract C {
|
||||
function f(int8 a, uint8 b) public returns (int8) {
|
||||
return a >> b;
|
||||
}
|
||||
}
|
||||
// ====
|
||||
// compileViaYul: also
|
||||
// ----
|
||||
// f(int8,uint8): 0x99, 0x00 -> FAILURE
|
||||
// f(int8,uint8): 0x99, 0x01 -> FAILURE
|
||||
// f(int8,uint8): 0x99, 0x02 -> FAILURE
|
||||
// f(int8,uint8): 0x99, 0x04 -> FAILURE
|
||||
// f(int8,uint8): 0x99, 0x08 -> FAILURE
|
||||
@@ -0,0 +1,13 @@
|
||||
contract C {
|
||||
function f(uint32 a, uint32 b) public returns (uint256) {
|
||||
return a >> b;
|
||||
}
|
||||
}
|
||||
|
||||
// ====
|
||||
// compileViaYul: also
|
||||
// ----
|
||||
// f(uint32,uint32): 0x4266, 0x0 -> 0x4266
|
||||
// f(uint32,uint32): 0x4266, 0x8 -> 0x42
|
||||
// f(uint32,uint32): 0x4266, 0x10 -> 0
|
||||
// f(uint32,uint32): 0x4266, 0x11 -> 0
|
||||
@@ -0,0 +1,11 @@
|
||||
contract C {
|
||||
function f(uint8 a, uint8 b) public returns (uint256) {
|
||||
return a >> b;
|
||||
}
|
||||
}
|
||||
|
||||
// ====
|
||||
// compileViaYul: also
|
||||
// ----
|
||||
// f(uint8,uint8): 0x66, 0x0 -> 0x66
|
||||
// f(uint8,uint8): 0x66, 0x8 -> 0x0
|
||||
@@ -0,0 +1,15 @@
|
||||
contract C {
|
||||
function f(int256 a, uint256 b) public returns (int256) {
|
||||
return a << b;
|
||||
}
|
||||
|
||||
function g(int256 a, uint256 b) public returns (int256) {
|
||||
return a >> b;
|
||||
}
|
||||
}
|
||||
|
||||
// ====
|
||||
// compileViaYul: also
|
||||
// ----
|
||||
// f(int256,uint256): 1, -1 -> 0
|
||||
// g(int256,uint256): 1, -1 -> 0
|
||||
@@ -0,0 +1,10 @@
|
||||
contract C {
|
||||
function f(uint x) public returns (uint y) {
|
||||
assembly { y := shl(2, x) }
|
||||
}
|
||||
}
|
||||
// ====
|
||||
// compileViaYul: also
|
||||
// EVMVersion: >=constantinople
|
||||
// ----
|
||||
// f(uint256): 7 -> 28
|
||||
Reference in New Issue
Block a user