From b86cea033bc3a31c15356b46e28e0f303490d52d Mon Sep 17 00:00:00 2001 From: Anurag Dashputre Date: Thu, 13 Sep 2018 15:40:06 +0530 Subject: [PATCH 1/2] Removed default case from "ExpressionCompiler::visit(FunctionCall...)". --- libsolidity/codegen/ExpressionCompiler.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/libsolidity/codegen/ExpressionCompiler.cpp b/libsolidity/codegen/ExpressionCompiler.cpp index 45e58bd07..23faeef50 100644 --- a/libsolidity/codegen/ExpressionCompiler.cpp +++ b/libsolidity/codegen/ExpressionCompiler.cpp @@ -1098,8 +1098,6 @@ bool ExpressionCompiler::visit(FunctionCall const& _functionCall) case FunctionType::Kind::GasLeft: m_context << Instruction::GAS; break; - default: - solAssert(false, "Invalid function type."); } } return false; From 3321000f67add785383adb4ec544aad121552751 Mon Sep 17 00:00:00 2001 From: Anurag Dashputre Date: Sun, 30 Sep 2018 12:40:38 +0530 Subject: [PATCH 2/2] Removing extra default cases to force compile time error, instead of runtime. --- libsolidity/ast/AST.cpp | 6 ------ libsolidity/ast/ASTJsonConverter.cpp | 9 +++++---- libsolidity/codegen/ArrayUtils.cpp | 2 -- libsolidity/codegen/CompilerUtils.cpp | 9 --------- libsolidity/formal/SMTChecker.cpp | 2 -- libsolidity/formal/Z3Interface.cpp | 2 -- libsolidity/interface/Exceptions.cpp | 3 --- 7 files changed, 5 insertions(+), 28 deletions(-) diff --git a/libsolidity/ast/AST.cpp b/libsolidity/ast/AST.cpp index 8e7a81a68..a11b11468 100644 --- a/libsolidity/ast/AST.cpp +++ b/libsolidity/ast/AST.cpp @@ -311,8 +311,6 @@ FunctionTypePointer FunctionDefinition::functionType(bool _internal) const return make_shared(*this, _internal); case Declaration::Visibility::External: return {}; - default: - solAssert(false, "visibility() should return a Visibility"); } } else @@ -327,8 +325,6 @@ FunctionTypePointer FunctionDefinition::functionType(bool _internal) const case Declaration::Visibility::Public: case Declaration::Visibility::External: return make_shared(*this, _internal); - default: - solAssert(false, "visibility() should return a Visibility"); } } @@ -568,8 +564,6 @@ FunctionTypePointer VariableDeclaration::functionType(bool _internal) const case Declaration::Visibility::Public: case Declaration::Visibility::External: return make_shared(*this); - default: - solAssert(false, "visibility() should not return a Visibility"); } // To make the compiler happy diff --git a/libsolidity/ast/ASTJsonConverter.cpp b/libsolidity/ast/ASTJsonConverter.cpp index beab356c2..4d41376a7 100644 --- a/libsolidity/ast/ASTJsonConverter.cpp +++ b/libsolidity/ast/ASTJsonConverter.cpp @@ -747,9 +747,9 @@ string ASTJsonConverter::location(VariableDeclaration::Location _location) return "memory"; case VariableDeclaration::Location::CallData: return "calldata"; - default: - solAssert(false, "Unknown declaration location."); } + // To make the compiler happy + return {}; } string ASTJsonConverter::contractKind(ContractDefinition::ContractKind _kind) @@ -762,9 +762,10 @@ string ASTJsonConverter::contractKind(ContractDefinition::ContractKind _kind) return "contract"; case ContractDefinition::ContractKind::Library: return "library"; - default: - solAssert(false, "Unknown kind of contract."); } + + // To make the compiler happy + return {}; } string ASTJsonConverter::functionCallKind(FunctionCallKind _kind) diff --git a/libsolidity/codegen/ArrayUtils.cpp b/libsolidity/codegen/ArrayUtils.cpp index 2b77db8f6..d33f749cf 100644 --- a/libsolidity/codegen/ArrayUtils.cpp +++ b/libsolidity/codegen/ArrayUtils.cpp @@ -1108,8 +1108,6 @@ void ArrayUtils::accessIndex(ArrayType const& _arrayType, bool _doBoundsCheck) c m_context << endTag; break; } - default: - solAssert(false, ""); } } diff --git a/libsolidity/codegen/CompilerUtils.cpp b/libsolidity/codegen/CompilerUtils.cpp index e6ad6d9ca..2bdf88e3a 100644 --- a/libsolidity/codegen/CompilerUtils.cpp +++ b/libsolidity/codegen/CompilerUtils.cpp @@ -895,15 +895,6 @@ void CompilerUtils::convertType( typeOnStack.location() == DataLocation::CallData, "Invalid conversion to calldata type."); break; - default: - solAssert( - false, - "Invalid type conversion " + - _typeOnStack.toString(false) + - " to " + - _targetType.toString(false) + - " requested." - ); } break; } diff --git a/libsolidity/formal/SMTChecker.cpp b/libsolidity/formal/SMTChecker.cpp index 49c90405c..197858179 100644 --- a/libsolidity/formal/SMTChecker.cpp +++ b/libsolidity/formal/SMTChecker.cpp @@ -639,8 +639,6 @@ void SMTChecker::checkCondition( case smt::CheckResult::ERROR: m_errorReporter.warning(_location, "Error trying to invoke SMT solver."); break; - default: - solAssert(false, ""); } m_interface->pop(); } diff --git a/libsolidity/formal/Z3Interface.cpp b/libsolidity/formal/Z3Interface.cpp index 747c91725..9a0ccf48b 100644 --- a/libsolidity/formal/Z3Interface.cpp +++ b/libsolidity/formal/Z3Interface.cpp @@ -91,8 +91,6 @@ pair> Z3Interface::check(vector const& _ case z3::check_result::unknown: result = CheckResult::UNKNOWN; break; - default: - solAssert(false, ""); } if (result == CheckResult::SATISFIABLE && !_expressionsToEvaluate.empty()) diff --git a/libsolidity/interface/Exceptions.cpp b/libsolidity/interface/Exceptions.cpp index a837dce65..ecadd0b7b 100644 --- a/libsolidity/interface/Exceptions.cpp +++ b/libsolidity/interface/Exceptions.cpp @@ -49,9 +49,6 @@ Error::Error(Type _type, SourceLocation const& _location, string const& _descrip case Type::Warning: m_typeName = "Warning"; break; - default: - solAssert(false, ""); - break; } if (!_location.isEmpty())