Browse Source

Merge pull request #885 from chriseth/sol_fix_typeType_size

Fix stack size of TypeTypes.
cl-refactor
chriseth 10 years ago
parent
commit
4e4ee15acb
  1. 2
      libsolidity/Types.h
  2. 16
      test/SolidityEndToEndTest.cpp

2
libsolidity/Types.h

@ -452,6 +452,7 @@ public:
virtual bool canBeStored() const override { return false; } virtual bool canBeStored() const override { return false; }
virtual u256 getStorageSize() const override { BOOST_THROW_EXCEPTION(InternalCompilerError() << errinfo_comment("Storage size of non-storable type type requested.")); } virtual u256 getStorageSize() const override { BOOST_THROW_EXCEPTION(InternalCompilerError() << errinfo_comment("Storage size of non-storable type type requested.")); }
virtual bool canLiveOutsideStorage() const override { return false; } virtual bool canLiveOutsideStorage() const override { return false; }
virtual unsigned getSizeOnStack() const override { return 0; }
virtual std::string toString() const override { return "type(" + m_actualType->toString() + ")"; } virtual std::string toString() const override { return "type(" + m_actualType->toString() + ")"; }
virtual MemberList const& getMembers() const override; virtual MemberList const& getMembers() const override;
@ -477,6 +478,7 @@ public:
virtual bool canBeStored() const override { return false; } virtual bool canBeStored() const override { return false; }
virtual u256 getStorageSize() const override { BOOST_THROW_EXCEPTION(InternalCompilerError() << errinfo_comment("Storage size of non-storable type type requested.")); } virtual u256 getStorageSize() const override { BOOST_THROW_EXCEPTION(InternalCompilerError() << errinfo_comment("Storage size of non-storable type type requested.")); }
virtual bool canLiveOutsideStorage() const override { return false; } virtual bool canLiveOutsideStorage() const override { return false; }
virtual unsigned getSizeOnStack() const override { return 0; }
virtual bool operator==(Type const& _other) const override; virtual bool operator==(Type const& _other) const override;
virtual std::string toString() const override; virtual std::string toString() const override;

16
test/SolidityEndToEndTest.cpp

@ -1877,6 +1877,22 @@ BOOST_AUTO_TEST_CASE(use_std_lib)
BOOST_CHECK(m_state.balance(m_sender) > balanceBefore); BOOST_CHECK(m_state.balance(m_sender) > balanceBefore);
} }
BOOST_AUTO_TEST_CASE(crazy_elementary_typenames_on_stack)
{
char const* sourceCode = R"(
contract C {
function f() returns (uint r) {
uint; uint; uint; uint;
int x = -7;
var a = uint;
return a(x);
}
}
)";
compileAndRun(sourceCode);
BOOST_CHECK(callContractFunction("f()") == encodeArgs(u256(-7)));
}
BOOST_AUTO_TEST_SUITE_END() BOOST_AUTO_TEST_SUITE_END()
} }

Loading…
Cancel
Save