diff options
author | chriseth <chris@ethereum.org> | 2017-02-20 22:20:12 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-02-20 22:20:12 +0800 |
commit | 32b7d17467abe02ebbd503e994092f718b92172f (patch) | |
tree | 932b523f9f470c52f211dd865549262fb3c342f5 | |
parent | 419ab9260ed817088f7e3b58a2ff01c47a3f7b9c (diff) | |
parent | c0961664f9666e5f4e8e35e80ef9a71426f6c394 (diff) | |
download | dexon-solidity-32b7d17467abe02ebbd503e994092f718b92172f.tar.gz dexon-solidity-32b7d17467abe02ebbd503e994092f718b92172f.tar.zst dexon-solidity-32b7d17467abe02ebbd503e994092f718b92172f.zip |
Merge pull request #1705 from ethereum/fixasmbug
Bugfix: Deposit one stack item for non-value types in inline assembly type checking.
-rw-r--r-- | Changelog.md | 1 | ||||
-rw-r--r-- | libsolidity/analysis/TypeChecker.cpp | 2 | ||||
-rw-r--r-- | test/libsolidity/SolidityNameAndTypeResolution.cpp | 13 |
3 files changed, 15 insertions, 1 deletions
diff --git a/Changelog.md b/Changelog.md index 72947dab..45aaf04a 100644 --- a/Changelog.md +++ b/Changelog.md @@ -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) diff --git a/libsolidity/analysis/TypeChecker.cpp b/libsolidity/analysis/TypeChecker.cpp index 28cb9acc..4025831e 100644 --- a/libsolidity/analysis/TypeChecker.cpp +++ b/libsolidity/analysis/TypeChecker.cpp @@ -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 diff --git a/test/libsolidity/SolidityNameAndTypeResolution.cpp b/test/libsolidity/SolidityNameAndTypeResolution.cpp index 507d9057..a1ebc300 100644 --- a/test/libsolidity/SolidityNameAndTypeResolution.cpp +++ b/test/libsolidity/SolidityNameAndTypeResolution.cpp @@ -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"( |