Merge pull request #2934 from ethereum/fallthrough

Remove last two instances of switch fall-through
This commit is contained in:
chriseth 2017-09-26 11:38:22 +02:00 committed by GitHub
commit af4d8779bb
2 changed files with 58 additions and 55 deletions

View File

@ -596,7 +596,6 @@ void CompilerUtils::convertType(
storeInMemoryDynamic(IntegerType(256));
// stack: mempos datapos
storeStringData(data);
break;
}
else
solAssert(
@ -810,9 +809,8 @@ void CompilerUtils::convertType(
if (_cleanupNeeded)
m_context << Instruction::ISZERO << Instruction::ISZERO;
break;
case Type::Category::Function:
{
if (targetTypeCategory == Type::Category::Integer)
default:
if (stackTypeCategory == Type::Category::Function && targetTypeCategory == Type::Category::Integer)
{
IntegerType const& targetType = dynamic_cast<IntegerType const&>(_targetType);
solAssert(targetType.isAddress(), "Function type can only be converted to address.");
@ -821,17 +819,16 @@ void CompilerUtils::convertType(
// stack: <address> <function_id>
m_context << Instruction::POP;
break;
}
}
// fall-through
default:
else
{
// All other types should not be convertible to non-equal types.
solAssert(_typeOnStack == _targetType, "Invalid type conversion requested.");
if (_cleanupNeeded && _targetType.canBeStored() && _targetType.storageBytes() < 32)
m_context
<< ((u256(1) << (8 * _targetType.storageBytes())) - 1)
<< Instruction::AND;
}
break;
}

View File

@ -1014,8 +1014,11 @@ bool ExpressionCompiler::visit(MemberAccess const& _memberAccess)
switch (_memberAccess.expression().annotation().type->category())
{
case Type::Category::Contract:
case Type::Category::Integer:
{
bool alsoSearchInteger = false;
if (_memberAccess.expression().annotation().type->category() == Type::Category::Contract)
{
ContractType const& type = dynamic_cast<ContractType const&>(*_memberAccess.expression().annotation().type);
if (type.isSuper())
{
@ -1044,11 +1047,12 @@ bool ExpressionCompiler::visit(MemberAccess const& _memberAccess)
// not found in contract, search in members inherited from address
alsoSearchInteger = true;
}
if (!alsoSearchInteger)
break;
}
// fall-through
case Type::Category::Integer:
else
alsoSearchInteger = true;
if (alsoSearchInteger)
{
if (member == "balance")
{
utils().convertType(
@ -1066,7 +1070,9 @@ bool ExpressionCompiler::visit(MemberAccess const& _memberAccess)
);
else
solAssert(false, "Invalid member access to integer");
}
break;
}
case Type::Category::Function:
if (member == "selector")
{