aboutsummaryrefslogtreecommitdiffstats
path: root/libsolidity
diff options
context:
space:
mode:
authorYoichi Hirai <i@yoichihirai.com>2016-11-09 21:14:18 +0800
committerYoichi Hirai <i@yoichihirai.com>2016-11-12 00:48:03 +0800
commit0a6c937dcbb3671e2fa5f6d7b50b5a909cf522d0 (patch)
treecab2ddcdd20a6930d68a8e0d0f28738bdc8393d8 /libsolidity
parenteffca182507bb736c8f52b167bae470c06dc6c36 (diff)
downloaddexon-solidity-0a6c937dcbb3671e2fa5f6d7b50b5a909cf522d0.tar
dexon-solidity-0a6c937dcbb3671e2fa5f6d7b50b5a909cf522d0.tar.gz
dexon-solidity-0a6c937dcbb3671e2fa5f6d7b50b5a909cf522d0.tar.bz2
dexon-solidity-0a6c937dcbb3671e2fa5f6d7b50b5a909cf522d0.tar.lz
dexon-solidity-0a6c937dcbb3671e2fa5f6d7b50b5a909cf522d0.tar.xz
dexon-solidity-0a6c937dcbb3671e2fa5f6d7b50b5a909cf522d0.tar.zst
dexon-solidity-0a6c937dcbb3671e2fa5f6d7b50b5a909cf522d0.zip
codegen: shorten the overflow checking when converting into enums
Diffstat (limited to 'libsolidity')
-rw-r--r--libsolidity/codegen/CompilerUtils.cpp3
1 files changed, 2 insertions, 1 deletions
diff --git a/libsolidity/codegen/CompilerUtils.cpp b/libsolidity/codegen/CompilerUtils.cpp
index 5e045996..ad155b13 100644
--- a/libsolidity/codegen/CompilerUtils.cpp
+++ b/libsolidity/codegen/CompilerUtils.cpp
@@ -661,7 +661,8 @@ void CompilerUtils::convertType(Type const& _typeOnStack, Type const& _targetTyp
if (targetTypeCategory == Type::Category::Enum)
{
EnumType const& enumType = dynamic_cast<decltype(enumType)>(_targetType);
- m_context << u256(enumType.numberOfMembers()) << Instruction::DUP2 << Instruction::LT << Instruction::ISZERO;
+ 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());
}
}