mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Merge remote-tracking branch 'origin/develop' into HEAD
This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
contract C {
|
||||
function f(bytes calldata x) public returns (C[] memory) {
|
||||
return abi.decode(x, (C[]));
|
||||
}
|
||||
function g() public returns (bytes memory) {
|
||||
C[] memory c = new C[](3);
|
||||
c[0] = C(address(0x42));
|
||||
c[1] = C(address(0x21));
|
||||
c[2] = C(address(0x23));
|
||||
return abi.encode(c);
|
||||
}
|
||||
}
|
||||
// ====
|
||||
// compileViaYul: also
|
||||
// ----
|
||||
// f(bytes): 0x20, 0xA0, 0x20, 3, 0x01, 0x02, 0x03 -> 0x20, 3, 0x01, 0x02, 0x03
|
||||
// g() -> 0x20, 0xa0, 0x20, 3, 0x42, 0x21, 0x23
|
||||
@@ -0,0 +1,20 @@
|
||||
pragma experimental ABIEncoderV2;
|
||||
contract C {
|
||||
function f(bytes calldata x) public returns (C[] memory) {
|
||||
return abi.decode(x, (C[]));
|
||||
}
|
||||
function g() public returns (bytes memory) {
|
||||
C[] memory c = new C[](3);
|
||||
c[0] = C(address(0x42));
|
||||
c[1] = C(address(0x21));
|
||||
c[2] = C(address(0x23));
|
||||
return abi.encode(c);
|
||||
}
|
||||
}
|
||||
// ====
|
||||
// compileViaYul: also
|
||||
// ----
|
||||
// f(bytes): 0x20, 0xA0, 0x20, 3, 0x01, 0x02, 0x03 -> 0x20, 3, 0x01, 0x02, 0x03
|
||||
// f(bytes): 0x20, 0x60, 0x20, 1, 0x0102030405060708090a0b0c0d0e0f1011121314 -> 0x20, 1, 0x0102030405060708090a0b0c0d0e0f1011121314
|
||||
// f(bytes): 0x20, 0x60, 0x20, 1, 0x0102030405060708090a0b0c0d0e0f101112131415 -> FAILURE
|
||||
// g() -> 0x20, 0xa0, 0x20, 3, 0x42, 0x21, 0x23
|
||||
@@ -32,6 +32,7 @@ contract c {
|
||||
data.push(bytes1(i));
|
||||
}
|
||||
data.pop();
|
||||
data.pop();
|
||||
assembly {
|
||||
r := sload(data.slot)
|
||||
}
|
||||
@@ -42,4 +43,4 @@ contract c {
|
||||
// ----
|
||||
// test_short() -> 1780731860627700044960722568376587075150542249149356309979516913770823710
|
||||
// test_long() -> 67
|
||||
// test_pop() -> 1780731860627700044960722568376592200742329637303199754547598369979440702
|
||||
// test_pop() -> 1780731860627700044960722568376592200742329637303199754547598369979433020
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
contract C {
|
||||
bytes data;
|
||||
|
||||
function f() public returns (uint ret) {
|
||||
data.push("a");
|
||||
data.push("b");
|
||||
delete data;
|
||||
assembly {
|
||||
ret := sload(data.slot)
|
||||
}
|
||||
}
|
||||
|
||||
function g() public returns (uint ret) {
|
||||
assembly {
|
||||
sstore(data.slot, 67)
|
||||
}
|
||||
data.push("a");
|
||||
data.push("b");
|
||||
assert(data.length == 35);
|
||||
delete data;
|
||||
assert(data.length == 0);
|
||||
|
||||
uint size = 999;
|
||||
assembly {
|
||||
size := sload(data.slot)
|
||||
mstore(0, data.slot)
|
||||
ret := sload(keccak256(0, 32))
|
||||
}
|
||||
assert(size == 0);
|
||||
}
|
||||
}
|
||||
|
||||
// ====
|
||||
// compileViaYul: also
|
||||
// ----
|
||||
// f() -> 0
|
||||
// g() -> 0
|
||||
@@ -1,53 +0,0 @@
|
||||
contract C {
|
||||
uint256[1024] s;
|
||||
function f() public returns (uint256 x) {
|
||||
x = 42;
|
||||
uint256 x0 = s[0];
|
||||
uint256 x1 = s[1];
|
||||
uint256 x2 = s[2];
|
||||
uint256 x3 = s[3];
|
||||
uint256 x4 = s[4];
|
||||
uint256 x5 = s[5];
|
||||
uint256 x6 = s[6];
|
||||
uint256 x7 = s[7];
|
||||
uint256 x8 = s[8];
|
||||
uint256 x9 = s[9];
|
||||
uint256 x10 = s[10];
|
||||
uint256 x11 = s[11];
|
||||
uint256 x12 = s[12];
|
||||
uint256 x13 = s[13];
|
||||
uint256 x14 = s[14];
|
||||
uint256 x15 = s[15];
|
||||
uint256 x16 = s[16];
|
||||
uint256 x17 = s[17];
|
||||
uint256 x18 = s[18];
|
||||
s[1000] = x0 + 2;
|
||||
s[118] = x18;
|
||||
s[117] = x17;
|
||||
s[116] = x16;
|
||||
s[115] = x15;
|
||||
s[114] = x14;
|
||||
s[113] = x13;
|
||||
s[112] = x12;
|
||||
s[111] = x11;
|
||||
s[110] = x10;
|
||||
s[109] = x9;
|
||||
s[108] = x8;
|
||||
s[107] = x7;
|
||||
s[106] = x6;
|
||||
s[105] = x5;
|
||||
s[104] = x4;
|
||||
s[103] = x3;
|
||||
s[102] = x2;
|
||||
s[101] = x1;
|
||||
s[100] = x0;
|
||||
}
|
||||
function test() public view returns(uint256) {
|
||||
return s[1000];
|
||||
}
|
||||
}
|
||||
// ====
|
||||
// compileViaYul: true
|
||||
// ----
|
||||
// f() -> 0x2a
|
||||
// test() -> 2
|
||||
@@ -1,57 +0,0 @@
|
||||
contract C {
|
||||
uint256[1024] s;
|
||||
function g() public returns (uint256) {
|
||||
// try to prevent inlining
|
||||
return f() + f() + f() + f() + f();
|
||||
}
|
||||
function f() public returns (uint256 x) {
|
||||
x = 42;
|
||||
uint256 x0 = s[0];
|
||||
uint256 x1 = s[1];
|
||||
uint256 x2 = s[2];
|
||||
uint256 x3 = s[3];
|
||||
uint256 x4 = s[4];
|
||||
uint256 x5 = s[5];
|
||||
uint256 x6 = s[6];
|
||||
uint256 x7 = s[7];
|
||||
uint256 x8 = s[8];
|
||||
uint256 x9 = s[9];
|
||||
uint256 x10 = s[10];
|
||||
uint256 x11 = s[11];
|
||||
uint256 x12 = s[12];
|
||||
uint256 x13 = s[13];
|
||||
uint256 x14 = s[14];
|
||||
uint256 x15 = s[15];
|
||||
uint256 x16 = s[16];
|
||||
uint256 x17 = s[17];
|
||||
uint256 x18 = s[18];
|
||||
s[1000] = x0 + 2;
|
||||
s[118] = x18;
|
||||
s[117] = x17;
|
||||
s[116] = x16;
|
||||
s[115] = x15;
|
||||
s[114] = x14;
|
||||
s[113] = x13;
|
||||
s[112] = x12;
|
||||
s[111] = x11;
|
||||
s[110] = x10;
|
||||
s[109] = x9;
|
||||
s[108] = x8;
|
||||
s[107] = x7;
|
||||
s[106] = x6;
|
||||
s[105] = x5;
|
||||
s[104] = x4;
|
||||
s[103] = x3;
|
||||
s[102] = x2;
|
||||
s[101] = x1;
|
||||
s[100] = x0;
|
||||
}
|
||||
function test() public view returns(uint256) {
|
||||
return s[1000];
|
||||
}
|
||||
}
|
||||
// ====
|
||||
// compileViaYul: true
|
||||
// ----
|
||||
// f() -> 0x2a
|
||||
// test() -> 2
|
||||
Reference in New Issue
Block a user