Merge pull request #1705 from ethereum/fixasmbug

Bugfix: Deposit one stack item for non-value types in inline assembly type checking.
This commit is contained in:
chriseth authored and GitHub committed 2017-02-20 15:20:12 +01:00
commit 32b7d17467
3 files changed
+15 -1

No files matched your search

+1
View File
@@ -11,6 +11,7 @@ Bugfixes:
* Commandline interface: Do not try creating paths ``.`` and ``..``.
* Type system: Fix a crash caused by continuing on fatal errors in the code.
* Type system: Disallow arrays with negative length.
* Inline assembly: Charge one stack slot for non-value types during analysis.
### 0.4.9 (2017-01-31)
+1 -1
View File
@@ -611,7 +611,7 @@ bool TypeChecker::visit(InlineAssembly const& _inlineAssembly)
fatalTypeError(SourceLocation(), "Constant variables not yet implemented for inline assembly.");
if (var->isLocalVariable())
pushes = var->type()->sizeOnStack();
else if (var->type()->isValueType())
else if (!var->type()->isValueType())
pushes = 1;
else
pushes = 2; // slot number, intra slot offset
@@ -4852,6 +4852,19 @@ BOOST_AUTO_TEST_CASE(inline_assembly_unbalanced_negative_stack)
CHECK_WARNING(text, "Inline assembly block is not balanced");
}
BOOST_AUTO_TEST_CASE(inline_assembly_unbalanced_two_stack_load)
{
char const* text = R"(
contract c {
uint8 x;
function f() {
assembly { x pop }
}
}
)";
CHECK_WARNING(text, "Inline assembly block is not balanced");
}
BOOST_AUTO_TEST_CASE(inline_assembly_in_modifier)
{
char const* text = R"(