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

View File

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