mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Analyze assembly.
This commit is contained in:
@@ -5234,7 +5234,7 @@ BOOST_AUTO_TEST_CASE(inline_assembly_storage_variable_access_out_of_functions)
|
||||
char const* text = R"(
|
||||
contract test {
|
||||
uint a;
|
||||
function f() {
|
||||
function f() pure {
|
||||
assembly {
|
||||
function g() -> x { x := a_slot }
|
||||
}
|
||||
@@ -5921,7 +5921,7 @@ BOOST_AUTO_TEST_CASE(no_unused_inline_asm)
|
||||
{
|
||||
char const* text = R"(
|
||||
contract C {
|
||||
function f() {
|
||||
function f() pure {
|
||||
uint a;
|
||||
assembly {
|
||||
a := 1
|
||||
|
||||
@@ -316,6 +316,68 @@ BOOST_AUTO_TEST_CASE(function_types)
|
||||
CHECK_SUCCESS_NO_WARNINGS(text);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(creation)
|
||||
{
|
||||
string text = R"(
|
||||
contract D {}
|
||||
contract C {
|
||||
function f() { new D(); }
|
||||
}
|
||||
)";
|
||||
CHECK_SUCCESS_NO_WARNINGS(text);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(assembly)
|
||||
{
|
||||
string text = R"(
|
||||
contract C {
|
||||
struct S { uint x; }
|
||||
S s;
|
||||
function e() pure {
|
||||
assembly { mstore(keccak256(0, 20), mul(s_slot, 2)) }
|
||||
}
|
||||
function f() pure {
|
||||
uint x;
|
||||
assembly { x := 7 }
|
||||
}
|
||||
function g() view {
|
||||
assembly { for {} 1 { pop(sload(0)) } { } }
|
||||
}
|
||||
function h() view {
|
||||
assembly { function g() { pop(blockhash(20)) } }
|
||||
}
|
||||
function j() {
|
||||
assembly { pop(call(0, 1, 2, 3, 4, 5, 6)) }
|
||||
}
|
||||
}
|
||||
)";
|
||||
CHECK_SUCCESS_NO_WARNINGS(text);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(assembly_staticcall)
|
||||
{
|
||||
string text = R"(
|
||||
contract C {
|
||||
function i() view {
|
||||
assembly { pop(staticcall(0, 1, 2, 3, 4, 5)) }
|
||||
}
|
||||
}
|
||||
)";
|
||||
CHECK_WARNING(text, "only available after the Metropolis");
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(assembly_jump)
|
||||
{
|
||||
string text = R"(
|
||||
contract C {
|
||||
function k() {
|
||||
assembly { jump(2) }
|
||||
}
|
||||
}
|
||||
)";
|
||||
CHECK_WARNING(text, "low-level EVM features");
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_SUITE_END()
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user