diff options
-rw-r--r-- | Changelog.md | 10 | ||||
-rw-r--r-- | libevmasm/Assembly.cpp | 6 | ||||
-rw-r--r-- | libsolidity/ast/Types.cpp | 8 | ||||
-rw-r--r-- | test/libsolidity/SolidityNameAndTypeResolution.cpp | 29 |
4 files changed, 45 insertions, 8 deletions
diff --git a/Changelog.md b/Changelog.md index 22db4f95..44f3183b 100644 --- a/Changelog.md +++ b/Changelog.md @@ -9,15 +9,17 @@ Features: * Support shifting constant numbers. Bugfixes: - * Disallow unknown options in ``solc``. - * Proper type checking for bound functions. - * Code Generator: expect zero stack increase after `super` as an expression. - * Allow inheritance of ``enum`` definitions. + * Commandline interface: Disallow unknown options in ``solc``. + * Name resolver: Allow inheritance of ``enum`` definitions. + * Type checker: Proper type checking for bound functions. + * Type checker: fix crash related to invalid fixed point constants + * Code generator: expect zero stack increase after ``super`` as an expression. * Inline assembly: support the ``address`` opcode. * Inline assembly: fix parsing of assignment after a label. * Inline assembly: external variables of unsupported type (such as ``this``, ``super``, etc.) are properly detected as unusable. * Inline assembly: support variables within modifiers. + * Optimizer: fix related to stale knowledge about SHA3 operations ### 0.4.2 (2016-09-17) diff --git a/libevmasm/Assembly.cpp b/libevmasm/Assembly.cpp index 450ee6ce..e881c1e2 100644 --- a/libevmasm/Assembly.cpp +++ b/libevmasm/Assembly.cpp @@ -327,8 +327,10 @@ Assembly& Assembly::optimise(bool _enable, bool _isCreation, size_t _runs) AssemblyItems optimisedItems; for (BasicBlock const& block: cfg.optimisedBlocks()) { - assertThrow(!!block.startState, OptimizerException, ""); - CommonSubexpressionEliminator eliminator(*block.startState); + // We used to start with the block's initial state but it caused + // too many inconsistencies. + KnownState emptyState; + CommonSubexpressionEliminator eliminator(emptyState); auto iter = m_items.begin() + block.begin; auto const end = m_items.begin() + block.end; while (iter < end) diff --git a/libsolidity/ast/Types.cpp b/libsolidity/ast/Types.cpp index eb98047c..88bdee9f 100644 --- a/libsolidity/ast/Types.cpp +++ b/libsolidity/ast/Types.cpp @@ -23,6 +23,7 @@ #include <libsolidity/ast/Types.h> #include <limits> #include <boost/range/adaptor/reversed.hpp> +#include <boost/range/adaptor/sliced.hpp> #include <libdevcore/CommonIO.h> #include <libdevcore/CommonData.h> #include <libdevcore/SHA3.h> @@ -482,7 +483,7 @@ tuple<bool, rational> RationalNumberType::isValidLiteral(Literal const& _literal !all_of(radixPoint + 1, _literal.value().end(), ::isdigit) || !all_of(_literal.value().begin(), radixPoint, ::isdigit) ) - throw; + return make_tuple(false, rational(0)); //Only decimal notation allowed here, leading zeros would switch to octal. auto fractionalBegin = find_if_not( radixPoint + 1, @@ -1324,7 +1325,10 @@ MemberList::MemberMap ContractType::nativeMembers(ContractDefinition const*) con if (m_super) { // add the most derived of all functions which are visible in derived contracts - for (ContractDefinition const* base: m_contract.annotation().linearizedBaseContracts) + auto bases = m_contract.annotation().linearizedBaseContracts; + solAssert(bases.size() >= 1, "linearizedBaseContracts should at least contain the most derived contract."); + // `sliced(1, ...)` ignores the most derived contract, which should not be searchable from `super`. + for (ContractDefinition const* base: bases | boost::adaptors::sliced(1, bases.size())) for (FunctionDefinition const* function: base->definedFunctions()) { if (!function->isVisibleInDerivedContracts()) diff --git a/test/libsolidity/SolidityNameAndTypeResolution.cpp b/test/libsolidity/SolidityNameAndTypeResolution.cpp index 74632860..44ac1511 100644 --- a/test/libsolidity/SolidityNameAndTypeResolution.cpp +++ b/test/libsolidity/SolidityNameAndTypeResolution.cpp @@ -854,6 +854,23 @@ BOOST_AUTO_TEST_CASE(implicit_base_to_derived_conversion) BOOST_CHECK(expectError(text) == Error::Type::TypeError); } +BOOST_AUTO_TEST_CASE(super_excludes_current_contract) +{ + char const* text = R"( + contract A { + function b() {} + } + + contract B is A { + function f() { + super.f(); + } + } + )"; + + BOOST_CHECK(expectError(text) == Error::Type::TypeError); +} + BOOST_AUTO_TEST_CASE(function_modifier_invocation) { char const* text = R"( @@ -4071,6 +4088,18 @@ BOOST_AUTO_TEST_CASE(using_directive_for_missing_selftype) BOOST_CHECK(expectError(text, false) == Error::Type::TypeError); } +BOOST_AUTO_TEST_CASE(invalid_fixed_point_literal) +{ + char const* text = R"( + contract A { + function a() { + .8E0; + } + } + )"; + BOOST_CHECK(expectError(text, false) == Error::Type::TypeError); +} + BOOST_AUTO_TEST_CASE(shift_constant_left_negative_rvalue) { char const* text = R"( |