mirror of
https://github.com/pezkuwichain/revive.git
synced 2026-04-22 12:38:03 +00:00
6858cb9a61
Prevents unused functions in the emitted ELF object. Drive-by add a missing test case (which misses a relocation under `-Oz` when all internal functions are marked as private). --------- Signed-off-by: Cyrill Leutwiler <bigcyrill@hotmail.com>
82 lines
1.8 KiB
Solidity
82 lines
1.8 KiB
Solidity
// SPDX-License-Identifier: GPL-3.0
|
|
|
|
pragma solidity ^0.8;
|
|
|
|
/* runner.json
|
|
{
|
|
"differential": true,
|
|
"actions": [
|
|
{
|
|
"Upload": {
|
|
"code": {
|
|
"Solidity": {
|
|
"contract": "AddModMulMod"
|
|
}
|
|
}
|
|
}
|
|
},
|
|
{
|
|
"Instantiate": {
|
|
"value": 123123,
|
|
"code": {
|
|
"Solidity": {
|
|
"contract": "AddModMulModTester"
|
|
}
|
|
}
|
|
}
|
|
},
|
|
{
|
|
"VerifyCall": {
|
|
"success": true
|
|
}
|
|
}
|
|
]
|
|
}
|
|
*/
|
|
|
|
contract AddModMulMod {
|
|
function test() public returns (uint256) {
|
|
// Note that this only works because computation on literals is done using
|
|
// unbounded integers.
|
|
if ((2**255 + 2**255) % 7 != addmod(2**255, 2**255, 7)) return 1;
|
|
if ((2**255 + 2**255) % 7 != addmod(2**255, 2**255, 7)) return 2;
|
|
return 0;
|
|
}
|
|
|
|
function f(uint256 d) public pure returns (uint256) {
|
|
addmod(1, 2, d);
|
|
return 2;
|
|
}
|
|
|
|
function g(uint256 d) public pure returns (uint256) {
|
|
mulmod(1, 2, d);
|
|
return 2;
|
|
}
|
|
|
|
function h() public pure returns (uint256) {
|
|
mulmod(0, 1, 2);
|
|
mulmod(1, 0, 2);
|
|
addmod(0, 1, 2);
|
|
addmod(1, 0, 2);
|
|
return 2;
|
|
}
|
|
}
|
|
|
|
contract AddModMulModTester {
|
|
constructor() payable {
|
|
AddModMulMod c = new AddModMulMod();
|
|
|
|
assert(c.test() == 0);
|
|
|
|
try c.f(0) returns (uint m) { revert(); } catch Panic(uint errorCode) {
|
|
assert(errorCode == 0x12);
|
|
}
|
|
|
|
try c.g(0) returns (uint m) { revert(); } catch Panic(uint errorCode) {
|
|
assert(errorCode == 0x12);
|
|
}
|
|
|
|
assert(c.h() == 2);
|
|
}
|
|
}
|