Merge pull request #2504 from ethereum/inlineasm-decl-empty

Support variable declarations without an assignment in assembly
This commit is contained in:
Alex Beregszaszi
2017-07-13 16:58:24 +02:00
committed by GitHub
9 changed files with 68 additions and 16 deletions
+5
View File
@@ -131,6 +131,11 @@ BOOST_AUTO_TEST_CASE(vardecl_bool)
BOOST_CHECK(successParse("{ let x:bool := false:bool }"));
}
BOOST_AUTO_TEST_CASE(vardecl_empty)
{
BOOST_CHECK(successParse("{ let x:u256 }"));
}
BOOST_AUTO_TEST_CASE(assignment)
{
BOOST_CHECK(successParse("{ let x:u256 := 2:u256 let y:u256 := x }"));
+5
View File
@@ -195,6 +195,11 @@ BOOST_AUTO_TEST_CASE(vardecl_bool)
CHECK_PARSE_ERROR("{ let x := false }", ParserError, "True and false are not valid literals.");
}
BOOST_AUTO_TEST_CASE(vardecl_empty)
{
BOOST_CHECK(successParse("{ let x }"));
}
BOOST_AUTO_TEST_CASE(assignment)
{
BOOST_CHECK(successParse("{ let x := 2 7 8 add =: x }"));
+18
View File
@@ -9723,6 +9723,24 @@ BOOST_AUTO_TEST_CASE(multi_modifiers)
BOOST_CHECK(callContractFunction("x()") == encodeArgs(u256(12)));
}
BOOST_AUTO_TEST_CASE(inlineasm_empty_let)
{
char const* sourceCode = R"(
contract C {
function f() returns (uint a, uint b) {
assembly {
let x
let y, z
a := x
b := z
}
}
}
)";
compileAndRun(sourceCode, 0, "C");
BOOST_CHECK(callContractFunction("f()") == encodeArgs(u256(0), u256(0)));
}
BOOST_AUTO_TEST_SUITE_END()
}