aboutsummaryrefslogtreecommitdiffstats
path: root/libsolidity
diff options
context:
space:
mode:
authorYoichi Hirai <i@yoichihirai.com>2016-11-15 00:09:53 +0800
committerYoichi Hirai <i@yoichihirai.com>2016-11-15 00:09:53 +0800
commitdbcbfafda8e44f56a7952993fd9f6699822395d6 (patch)
tree5157a5aa763e29b247246239706f3b9b5954bc1b /libsolidity
parent454e7618c8ebd35d442c43a66b2f95b36a4cd1d5 (diff)
downloaddexon-solidity-dbcbfafda8e44f56a7952993fd9f6699822395d6.tar
dexon-solidity-dbcbfafda8e44f56a7952993fd9f6699822395d6.tar.gz
dexon-solidity-dbcbfafda8e44f56a7952993fd9f6699822395d6.tar.bz2
dexon-solidity-dbcbfafda8e44f56a7952993fd9f6699822395d6.tar.lz
dexon-solidity-dbcbfafda8e44f56a7952993fd9f6699822395d6.tar.xz
dexon-solidity-dbcbfafda8e44f56a7952993fd9f6699822395d6.tar.zst
dexon-solidity-dbcbfafda8e44f56a7952993fd9f6699822395d6.zip
codegen: overflow checking also during conversion from enums
Diffstat (limited to 'libsolidity')
-rw-r--r--libsolidity/codegen/CompilerUtils.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/libsolidity/codegen/CompilerUtils.cpp b/libsolidity/codegen/CompilerUtils.cpp
index dd133aea..9472aac5 100644
--- a/libsolidity/codegen/CompilerUtils.cpp
+++ b/libsolidity/codegen/CompilerUtils.cpp
@@ -315,7 +315,7 @@ void CompilerUtils::convertType(Type const& _typeOnStack, Type const& _targetTyp
Type::Category stackTypeCategory = _typeOnStack.category();
Type::Category targetTypeCategory = _targetType.category();
- bool enumOverflowCheckPending = (targetTypeCategory == Type::Category::Enum);
+ bool enumOverflowCheckPending = (targetTypeCategory == Type::Category::Enum || stackTypeCategory == Type::Category::Enum);
switch (stackTypeCategory)
{
@@ -353,7 +353,7 @@ void CompilerUtils::convertType(Type const& _typeOnStack, Type const& _targetTyp
solAssert(_targetType == _typeOnStack || targetTypeCategory == Type::Category::Integer, "");
if (enumOverflowCheckPending)
{
- EnumType const& enumType = dynamic_cast<decltype(enumType)>(_targetType);
+ EnumType const& enumType = dynamic_cast<decltype(enumType)>(_typeOnStack);
solAssert(enumType.numberOfMembers() > 0, "empty enum should have caused a parser error.");
m_context << u256(enumType.numberOfMembers() - 1) << Instruction::DUP2 << Instruction::GT;
m_context.appendConditionalJumpTo(m_context.errorTag());