diff --git a/Changelog.md b/Changelog.md index 8032b6625..9c2939108 100644 --- a/Changelog.md +++ b/Changelog.md @@ -59,6 +59,7 @@ Build System: Bugfixes: * SMTChecker: Fix internal error when using ``abi.decode``. * SMTChecker: Fix internal error when using arrays or mappings of functions. + * SMTChecker: Fix internal error in array of structs type. diff --git a/docs/index.rst b/docs/index.rst index d1ac873de..15dea172d 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -66,6 +66,7 @@ They have varying degrees of completeness and up-to-dateness. The English version stands as a reference. * `French `_ (in progress) +* `Italian `_ (in progress) * `Japanese `_ * `Korean `_ (in progress) * `Russian `_ (rather outdated) diff --git a/libdevcore/JSON.cpp b/libdevcore/JSON.cpp index 80c116bbe..5d1ea831d 100644 --- a/libdevcore/JSON.cpp +++ b/libdevcore/JSON.cpp @@ -111,16 +111,4 @@ bool jsonParseStrict(string const& _input, Json::Value& _json, string* _errs /* return parse(readerBuilder, _input, _json, _errs); } -bool jsonParse(string const& _input, Json::Value& _json, string *_errs /* = nullptr */) -{ - static Json::CharReaderBuilder readerBuilder; - return parse(readerBuilder, _input, _json, _errs); -} - -bool jsonParseFile(string const& _fileName, Json::Value& _json, string *_errs /* = nullptr */) -{ - return jsonParse(readFileAsString(_fileName), _json, _errs); -} - - } // namespace dev diff --git a/libdevcore/JSON.h b/libdevcore/JSON.h index ecb934673..2390d55f2 100644 --- a/libdevcore/JSON.h +++ b/libdevcore/JSON.h @@ -41,18 +41,4 @@ std::string jsonCompactPrint(Json::Value const& _input); /// \return \c true if the document was successfully parsed, \c false if an error occurred. bool jsonParseStrict(std::string const& _input, Json::Value& _json, std::string* _errs = nullptr); -/// Parse a JSON string (@a _input) and writes resulting JSON object to (@a _json) -/// \param _input JSON input string -/// \param _json [out] resulting JSON object -/// \param _errs [out] Formatted error messages -/// \return \c true if the document was successfully parsed, \c false if an error occurred. -bool jsonParse(std::string const& _input, Json::Value& _json, std::string* _errs = nullptr); - -/// Parse a JSON string (@a _input) and writes resulting JSON object to (@a _json) -/// \param _input file containing JSON input -/// \param _json [out] resulting JSON object -/// \param _errs [out] Formatted error messages -/// \return \c true if the document was successfully parsed, \c false if an error occurred. -bool jsonParseFile(std::string const& _fileName, Json::Value& _json, std::string* _errs = nullptr); - } diff --git a/libsolidity/formal/SMTEncoder.cpp b/libsolidity/formal/SMTEncoder.cpp index 6fb85a15c..70b4a6c9f 100644 --- a/libsolidity/formal/SMTEncoder.cpp +++ b/libsolidity/formal/SMTEncoder.cpp @@ -870,8 +870,11 @@ void SMTEncoder::endVisit(IndexAccess const& _indexAccess) { createExpr(_indexAccess); + if (_indexAccess.annotation().type->category() == Type::Category::TypeType) + return; + shared_ptr array; - if (auto const& id = dynamic_cast(&_indexAccess.baseExpression())) + if (auto const* id = dynamic_cast(&_indexAccess.baseExpression())) { auto varDecl = identifierToVariable(*id); solAssert(varDecl, ""); @@ -886,7 +889,7 @@ void SMTEncoder::endVisit(IndexAccess const& _indexAccess) return; } } - else if (auto const& innerAccess = dynamic_cast(&_indexAccess.baseExpression())) + else if (auto const* innerAccess = dynamic_cast(&_indexAccess.baseExpression())) { solAssert(m_context.knownExpression(*innerAccess), ""); array = m_context.expression(*innerAccess); @@ -900,9 +903,6 @@ void SMTEncoder::endVisit(IndexAccess const& _indexAccess) return; } - if (_indexAccess.annotation().type->category() == Type::Category::TypeType) - return; - solAssert(array, ""); defineExpr(_indexAccess, smt::Expression::select( array->currentValue(), diff --git a/libsolidity/interface/StandardCompiler.cpp b/libsolidity/interface/StandardCompiler.cpp index fd927828e..7e1fa8467 100644 --- a/libsolidity/interface/StandardCompiler.cpp +++ b/libsolidity/interface/StandardCompiler.cpp @@ -24,6 +24,7 @@ #include #include +#include #include #include #include @@ -857,6 +858,16 @@ Json::Value StandardCompiler::compileSolidity(StandardCompiler::InputsAndSetting "Unimplemented feature (" + _exception.lineInfo() + ")" )); } + catch (yul::YulException const& _exception) + { + errors.append(formatErrorWithException( + _exception, + false, + "YulException", + "general", + "Yul exception" + )); + } catch (Exception const& _exception) { errors.append(formatError( diff --git a/libyul/AsmAnalysis.cpp b/libyul/AsmAnalysis.cpp index 12b5c7940..64b1ad4c5 100644 --- a/libyul/AsmAnalysis.cpp +++ b/libyul/AsmAnalysis.cpp @@ -60,12 +60,12 @@ bool AsmAnalyzer::analyze(Block const& _block) success = (*this)(_block); if (!success) - solAssert(m_errorReporter.hasErrors(), "No success but no error."); + yulAssert(m_errorReporter.hasErrors(), "No success but no error."); } catch (FatalError const&) { // This FatalError con occur if the errorReporter has too many errors. - solAssert(!m_errorReporter.errors().empty(), "Fatal error detected, but no error is reported."); + yulAssert(!m_errorReporter.errors().empty(), "Fatal error detected, but no error is reported."); } return success && !m_errorReporter.hasErrors(); } @@ -82,13 +82,13 @@ AsmAnalysisInfo AsmAnalyzer::analyzeStrictAssertCorrect(Dialect const& _dialect, {}, _object.dataNames() ).analyze(*_object.code); - solAssert(success && errorList.empty(), "Invalid assembly/yul code."); + yulAssert(success && errorList.empty(), "Invalid assembly/yul code."); return analysisInfo; } bool AsmAnalyzer::operator()(yul::Instruction const& _instruction) { - solAssert(false, "The use of non-functional instructions is disallowed. Please use functional notation instead."); + yulAssert(false, "The use of non-functional instructions is disallowed. Please use functional notation instead."); auto const& info = instructionInfo(_instruction.instruction); m_stackHeight += info.ret - info.args; m_info.stackHeightInfo[&_instruction] = m_stackHeight; @@ -118,8 +118,8 @@ bool AsmAnalyzer::operator()(Literal const& _literal) } else if (_literal.kind == LiteralKind::Boolean) { - solAssert(m_dialect.flavour == AsmFlavour::Yul, ""); - solAssert(_literal.value == "true"_yulstring || _literal.value == "false"_yulstring, ""); + yulAssert(m_dialect.flavour == AsmFlavour::Yul, ""); + yulAssert(_literal.value == "true"_yulstring || _literal.value == "false"_yulstring, ""); } m_info.stackHeightInfo[&_literal] = m_stackHeight; return true; @@ -127,7 +127,7 @@ bool AsmAnalyzer::operator()(Literal const& _literal) bool AsmAnalyzer::operator()(Identifier const& _identifier) { - solAssert(!_identifier.name.empty(), ""); + yulAssert(!_identifier.name.empty(), ""); size_t numErrorsBefore = m_errorReporter.errors().size(); bool success = true; if (m_currentScope->lookup(_identifier.name, GenericVisitor{ @@ -200,9 +200,9 @@ bool AsmAnalyzer::operator()(ExpressionStatement const& _statement) bool AsmAnalyzer::operator()(Assignment const& _assignment) { - solAssert(_assignment.value, ""); + yulAssert(_assignment.value, ""); int const expectedItems = _assignment.variableNames.size(); - solAssert(expectedItems >= 1, ""); + yulAssert(expectedItems >= 1, ""); int const stackHeight = m_stackHeight; bool success = std::visit(*this, *_assignment.value); if ((m_stackHeight - stackHeight) != expectedItems) @@ -269,9 +269,9 @@ bool AsmAnalyzer::operator()(VariableDeclaration const& _varDecl) bool AsmAnalyzer::operator()(FunctionDefinition const& _funDef) { - solAssert(!_funDef.name.empty(), ""); + yulAssert(!_funDef.name.empty(), ""); Block const* virtualBlock = m_info.virtualBlocks.at(&_funDef).get(); - solAssert(virtualBlock, ""); + yulAssert(virtualBlock, ""); Scope& varScope = scope(virtualBlock); for (auto const& var: _funDef.parameters + _funDef.returnVariables) { @@ -291,7 +291,7 @@ bool AsmAnalyzer::operator()(FunctionDefinition const& _funDef) bool AsmAnalyzer::operator()(FunctionCall const& _funCall) { - solAssert(!_funCall.functionName.name.empty(), ""); + yulAssert(!_funCall.functionName.name.empty(), ""); bool success = true; size_t parameters = 0; size_t returns = 0; @@ -390,7 +390,7 @@ bool AsmAnalyzer::operator()(If const& _if) bool AsmAnalyzer::operator()(Switch const& _switch) { - solAssert(_switch.expression, ""); + yulAssert(_switch.expression, ""); bool success = true; @@ -462,7 +462,7 @@ bool AsmAnalyzer::operator()(Switch const& _switch) bool AsmAnalyzer::operator()(ForLoop const& _for) { - solAssert(_for.condition, ""); + yulAssert(_for.condition, ""); Scope* outerScope = m_currentScope; @@ -579,7 +579,7 @@ bool AsmAnalyzer::expectDeposit(int _deposit, int _oldHeight, SourceLocation con bool AsmAnalyzer::checkAssignment(Identifier const& _variable, size_t _valueSize) { - solAssert(!_variable.name.empty(), ""); + yulAssert(!_variable.name.empty(), ""); bool success = true; size_t numErrorsBefore = m_errorReporter.errors().size(); size_t variableSize(-1); @@ -635,9 +635,9 @@ bool AsmAnalyzer::checkAssignment(Identifier const& _variable, size_t _valueSize Scope& AsmAnalyzer::scope(Block const* _block) { - solAssert(m_info.scopes.count(_block) == 1, "Scope requested but not present."); + yulAssert(m_info.scopes.count(_block) == 1, "Scope requested but not present."); auto scopePtr = m_info.scopes.at(_block); - solAssert(scopePtr, "Scope requested but not present."); + yulAssert(scopePtr, "Scope requested but not present."); return *scopePtr; } void AsmAnalyzer::expectValidType(string const& type, SourceLocation const& _location) @@ -665,10 +665,10 @@ bool AsmAnalyzer::warnOnInstructions(dev::eth::Instruction _instr, SourceLocatio { // We assume that returndatacopy, returndatasize and staticcall are either all available // or all not available. - solAssert(m_evmVersion.supportsReturndata() == m_evmVersion.hasStaticCall(), ""); + yulAssert(m_evmVersion.supportsReturndata() == m_evmVersion.hasStaticCall(), ""); // Similarly we assume bitwise shifting and create2 go together. - solAssert(m_evmVersion.hasBitwiseShifting() == m_evmVersion.hasCreate2(), ""); - solAssert(m_dialect.flavour != AsmFlavour::Yul, ""); + yulAssert(m_evmVersion.hasBitwiseShifting() == m_evmVersion.hasCreate2(), ""); + yulAssert(m_dialect.flavour != AsmFlavour::Yul, ""); auto errorForVM = [=](string const& vmKindMessage) { m_errorReporter.typeError( diff --git a/libyul/AsmAnalysisInfo.h b/libyul/AsmAnalysisInfo.h index 08a35ade0..1201399a2 100644 --- a/libyul/AsmAnalysisInfo.h +++ b/libyul/AsmAnalysisInfo.h @@ -22,8 +22,6 @@ #include -#include - #include #include #include diff --git a/libyul/AsmParser.cpp b/libyul/AsmParser.cpp index 1a53da745..1123487e5 100644 --- a/libyul/AsmParser.cpp +++ b/libyul/AsmParser.cpp @@ -21,6 +21,7 @@ */ #include +#include #include #include #include @@ -52,7 +53,7 @@ shared_ptr Parser::parse(std::shared_ptr const& _scanner, bool _ } catch (FatalError const&) { - solAssert(!m_errorReporter.errors().empty(), "Fatal error detected, but no error is reported."); + yulAssert(!m_errorReporter.errors().empty(), "Fatal error detected, but no error is reported."); } return nullptr; @@ -232,7 +233,7 @@ Statement Parser::parseStatement() } else { - solAssert(false, "Invalid elementary operation."); + yulAssert(false, "Invalid elementary operation."); return {}; } } @@ -252,7 +253,7 @@ Case Parser::parseCase() _case.value = make_unique(std::get(std::move(literal))); } else - solAssert(false, "Case or default case expected."); + yulAssert(false, "Case or default case expected."); _case.body = parseBlock(); _case.location.end = _case.body.location.end; return _case; @@ -292,7 +293,7 @@ Expression Parser::parseExpression() return std::get(operation); else { - solAssert(holds_alternative(operation), ""); + yulAssert(holds_alternative(operation), ""); return std::get(operation); } } diff --git a/libyul/AsmPrinter.cpp b/libyul/AsmPrinter.cpp index d80c206df..6297ad695 100644 --- a/libyul/AsmPrinter.cpp +++ b/libyul/AsmPrinter.cpp @@ -22,7 +22,7 @@ #include #include -#include +#include #include @@ -44,10 +44,10 @@ string AsmPrinter::operator()(Literal const& _literal) const switch (_literal.kind) { case LiteralKind::Number: - solAssert(isValidDecimal(_literal.value.str()) || isValidHex(_literal.value.str()), "Invalid number literal"); + yulAssert(isValidDecimal(_literal.value.str()) || isValidHex(_literal.value.str()), "Invalid number literal"); return _literal.value.str() + appendTypeName(_literal.type); case LiteralKind::Boolean: - solAssert(_literal.value == "true"_yulstring || _literal.value == "false"_yulstring, "Invalid bool literal."); + yulAssert(_literal.value == "true"_yulstring || _literal.value == "false"_yulstring, "Invalid bool literal."); return ((_literal.value == "true"_yulstring) ? "true" : "false") + appendTypeName(_literal.type); case LiteralKind::String: break; @@ -84,7 +84,7 @@ string AsmPrinter::operator()(Literal const& _literal) const string AsmPrinter::operator()(Identifier const& _identifier) const { - solAssert(!_identifier.name.empty(), "Invalid identifier."); + yulAssert(!_identifier.name.empty(), "Invalid identifier."); return _identifier.name.str(); } @@ -95,7 +95,7 @@ string AsmPrinter::operator()(ExpressionStatement const& _statement) const string AsmPrinter::operator()(Assignment const& _assignment) const { - solAssert(_assignment.variableNames.size() >= 1, ""); + yulAssert(_assignment.variableNames.size() >= 1, ""); string variables = (*this)(_assignment.variableNames.front()); for (size_t i = 1; i < _assignment.variableNames.size(); ++i) variables += ", " + (*this)(_assignment.variableNames[i]); @@ -121,7 +121,7 @@ string AsmPrinter::operator()(VariableDeclaration const& _variableDeclaration) c string AsmPrinter::operator()(FunctionDefinition const& _functionDefinition) const { - solAssert(!_functionDefinition.name.empty(), "Invalid function name."); + yulAssert(!_functionDefinition.name.empty(), "Invalid function name."); string out = "function " + _functionDefinition.name.str() + "("; out += boost::algorithm::join( _functionDefinition.parameters | boost::adaptors::transformed( @@ -156,7 +156,7 @@ string AsmPrinter::operator()(FunctionCall const& _functionCall) const string AsmPrinter::operator()(If const& _if) const { - solAssert(_if.condition, "Invalid if condition."); + yulAssert(_if.condition, "Invalid if condition."); string body = (*this)(_if.body); char delim = '\n'; if (body.find('\n') == string::npos) @@ -166,7 +166,7 @@ string AsmPrinter::operator()(If const& _if) const string AsmPrinter::operator()(Switch const& _switch) const { - solAssert(_switch.expression, "Invalid expression pointer."); + yulAssert(_switch.expression, "Invalid expression pointer."); string out = "switch " + std::visit(*this, *_switch.expression); for (auto const& _case: _switch.cases) { @@ -181,7 +181,7 @@ string AsmPrinter::operator()(Switch const& _switch) const string AsmPrinter::operator()(ForLoop const& _forLoop) const { - solAssert(_forLoop.condition, "Invalid for loop condition."); + yulAssert(_forLoop.condition, "Invalid for loop condition."); string pre = (*this)(_forLoop.pre); string condition = std::visit(*this, *_forLoop.condition); string post = (*this)(_forLoop.post); @@ -231,7 +231,7 @@ string AsmPrinter::operator()(Block const& _block) const string AsmPrinter::formatTypedName(TypedName _variable) const { - solAssert(!_variable.name.empty(), "Invalid variable name."); + yulAssert(!_variable.name.empty(), "Invalid variable name."); return _variable.name.str() + appendTypeName(_variable.type); } diff --git a/libyul/AsmScopeFiller.cpp b/libyul/AsmScopeFiller.cpp index e93cc93c4..b131e988a 100644 --- a/libyul/AsmScopeFiller.cpp +++ b/libyul/AsmScopeFiller.cpp @@ -23,9 +23,9 @@ #include #include #include +#include #include -#include #include @@ -74,7 +74,7 @@ bool ScopeFiller::operator()(FunctionDefinition const& _funDef) if (!(*this)(_funDef.body)) success = false; - solAssert(m_currentScope == &varScope, ""); + yulAssert(m_currentScope == &varScope, ""); m_currentScope = m_currentScope->superScope; return success; diff --git a/libyul/AssemblyStack.cpp b/libyul/AssemblyStack.cpp index 5198aacf2..6dc84ac81 100644 --- a/libyul/AssemblyStack.cpp +++ b/libyul/AssemblyStack.cpp @@ -62,7 +62,7 @@ Dialect const& languageToDialect(AssemblyStack::Language _language, EVMVersion _ case AssemblyStack::Language::EWasm: return WasmDialect::instance(); } - solAssert(false, ""); + yulAssert(false, ""); return Dialect::yul(); } @@ -71,7 +71,7 @@ Dialect const& languageToDialect(AssemblyStack::Language _language, EVMVersion _ Scanner const& AssemblyStack::scanner() const { - solAssert(m_scanner, ""); + yulAssert(m_scanner, ""); return *m_scanner; } @@ -83,8 +83,8 @@ bool AssemblyStack::parseAndAnalyze(std::string const& _sourceName, std::string m_parserResult = ObjectParser(m_errorReporter, languageToDialect(m_language, m_evmVersion)).parse(m_scanner, false); if (!m_errorReporter.errors().empty()) return false; - solAssert(m_parserResult, ""); - solAssert(m_parserResult->code, ""); + yulAssert(m_parserResult, ""); + yulAssert(m_parserResult->code, ""); return analyzeParsed(); } @@ -94,12 +94,12 @@ void AssemblyStack::optimize() if (!m_optimiserSettings.runYulOptimiser) return; - solAssert(m_analysisSuccessful, "Analysis was not successful."); + yulAssert(m_analysisSuccessful, "Analysis was not successful."); m_analysisSuccessful = false; - solAssert(m_parserResult, ""); + yulAssert(m_parserResult, ""); optimize(*m_parserResult, true); - solAssert(analyzeParsed(), "Invalid source code after optimization."); + yulAssert(analyzeParsed(), "Invalid source code after optimization."); } void AssemblyStack::translate(AssemblyStack::Language _targetLanguage) @@ -121,14 +121,14 @@ void AssemblyStack::translate(AssemblyStack::Language _targetLanguage) bool AssemblyStack::analyzeParsed() { - solAssert(m_parserResult, ""); + yulAssert(m_parserResult, ""); m_analysisSuccessful = analyzeParsed(*m_parserResult); return m_analysisSuccessful; } bool AssemblyStack::analyzeParsed(Object& _object) { - solAssert(_object.code, ""); + yulAssert(_object.code, ""); _object.analysisInfo = make_shared(); AsmAnalyzer analyzer( @@ -168,8 +168,8 @@ void AssemblyStack::compileEVM(AbstractAssembly& _assembly, bool _evm15, bool _o void AssemblyStack::optimize(Object& _object, bool _isCreation) { - solAssert(_object.code, ""); - solAssert(_object.analysisInfo, ""); + yulAssert(_object.code, ""); + yulAssert(_object.analysisInfo, ""); for (auto& subNode: _object.subObjects) if (auto subObject = dynamic_cast(subNode.get())) optimize(*subObject, false); @@ -188,10 +188,10 @@ void AssemblyStack::optimize(Object& _object, bool _isCreation) MachineAssemblyObject AssemblyStack::assemble(Machine _machine) const { - solAssert(m_analysisSuccessful, ""); - solAssert(m_parserResult, ""); - solAssert(m_parserResult->code, ""); - solAssert(m_parserResult->analysisInfo, ""); + yulAssert(m_analysisSuccessful, ""); + yulAssert(m_parserResult, ""); + yulAssert(m_parserResult->code, ""); + yulAssert(m_parserResult->analysisInfo, ""); switch (_machine) { @@ -216,7 +216,7 @@ MachineAssemblyObject AssemblyStack::assemble(Machine _machine) const } case Machine::eWasm: { - solAssert(m_language == Language::EWasm, ""); + yulAssert(m_language == Language::EWasm, ""); Dialect const& dialect = languageToDialect(m_language, EVMVersion{}); MachineAssemblyObject object; @@ -233,15 +233,15 @@ MachineAssemblyObject AssemblyStack::assemble(Machine _machine) const string AssemblyStack::print() const { - solAssert(m_parserResult, ""); - solAssert(m_parserResult->code, ""); + yulAssert(m_parserResult, ""); + yulAssert(m_parserResult->code, ""); return m_parserResult->toString(m_language == Language::Yul) + "\n"; } shared_ptr AssemblyStack::parserResult() const { - solAssert(m_analysisSuccessful, "Analysis was not successful."); - solAssert(m_parserResult, ""); - solAssert(m_parserResult->code, ""); + yulAssert(m_analysisSuccessful, "Analysis was not successful."); + yulAssert(m_parserResult, ""); + yulAssert(m_parserResult->code, ""); return m_parserResult; } diff --git a/libyul/CompilabilityChecker.cpp b/libyul/CompilabilityChecker.cpp index 7c6fe9d78..228515b9b 100644 --- a/libyul/CompilabilityChecker.cpp +++ b/libyul/CompilabilityChecker.cpp @@ -41,7 +41,7 @@ map CompilabilityChecker::run( if (_dialect.flavour == AsmFlavour::Yul) return {}; - solAssert(_dialect.flavour == AsmFlavour::Strict, ""); + yulAssert(_dialect.flavour == AsmFlavour::Strict, ""); if (EVMDialect const* evmDialect = dynamic_cast(&_dialect)) { @@ -69,7 +69,7 @@ map CompilabilityChecker::run( } catch (StackTooDeepError const&) { - solAssert(!transform.stackErrors().empty(), "Got stack too deep exception that was not stored."); + yulAssert(!transform.stackErrors().empty(), "Got stack too deep exception that was not stored."); } std::map functions; diff --git a/libyul/Exceptions.h b/libyul/Exceptions.h index 3e1e4155b..7ce1a8066 100644 --- a/libyul/Exceptions.h +++ b/libyul/Exceptions.h @@ -33,6 +33,6 @@ struct YulAssertion: virtual YulException {}; /// Assertion that throws an YulAssertion containing the given description if it is not met. #define yulAssert(CONDITION, DESCRIPTION) \ - assertThrow(CONDITION, ::yul::YulException, DESCRIPTION) + assertThrow(CONDITION, ::yul::YulAssertion, DESCRIPTION) } diff --git a/libyul/ObjectParser.cpp b/libyul/ObjectParser.cpp index 2e201046f..683b8022b 100644 --- a/libyul/ObjectParser.cpp +++ b/libyul/ObjectParser.cpp @@ -112,7 +112,7 @@ shared_ptr ObjectParser::parseBlock() void ObjectParser::parseData(Object& _containingObject) { - solAssert( + yulAssert( currentToken() == Token::Identifier && currentLiteral() == "data", "parseData called on wrong input." ); diff --git a/libyul/backends/evm/AsmCodeGen.cpp b/libyul/backends/evm/AsmCodeGen.cpp index ca0aeb86a..9022dadad 100644 --- a/libyul/backends/evm/AsmCodeGen.cpp +++ b/libyul/backends/evm/AsmCodeGen.cpp @@ -118,19 +118,19 @@ void EthAssemblyAdapter::appendJumpToIf(LabelID _labelId) void EthAssemblyAdapter::appendBeginsub(LabelID, int) { // TODO we could emulate that, though - solAssert(false, "BEGINSUB not implemented for EVM 1.0"); + yulAssert(false, "BEGINSUB not implemented for EVM 1.0"); } void EthAssemblyAdapter::appendJumpsub(LabelID, int, int) { // TODO we could emulate that, though - solAssert(false, "JUMPSUB not implemented for EVM 1.0"); + yulAssert(false, "JUMPSUB not implemented for EVM 1.0"); } void EthAssemblyAdapter::appendReturnsub(int, int) { // TODO we could emulate that, though - solAssert(false, "RETURNSUB not implemented for EVM 1.0"); + yulAssert(false, "RETURNSUB not implemented for EVM 1.0"); } void EthAssemblyAdapter::appendAssemblySize() @@ -174,7 +174,7 @@ AbstractAssembly::SubID EthAssemblyAdapter::appendData(bytes const& _data) EthAssemblyAdapter::LabelID EthAssemblyAdapter::assemblyTagToIdentifier(eth::AssemblyItem const& _tag) { u256 id = _tag.data(); - solAssert(id <= std::numeric_limits::max(), "Tag id too large."); + yulAssert(id <= std::numeric_limits::max(), "Tag id too large."); return LabelID(id); } @@ -207,11 +207,11 @@ void CodeGenerator::assemble( } catch (StackTooDeepError const& _e) { - solAssert( + yulAssert( false, "Stack too deep when compiling inline assembly" + (_e.comment() ? ": " + *_e.comment() : ".") ); } - solAssert(transform.stackErrors().empty(), "Stack errors present but not thrown."); + yulAssert(transform.stackErrors().empty(), "Stack errors present but not thrown."); } diff --git a/libyul/backends/evm/EVMAssembly.cpp b/libyul/backends/evm/EVMAssembly.cpp index 65d22cbd8..6b268e67d 100644 --- a/libyul/backends/evm/EVMAssembly.cpp +++ b/libyul/backends/evm/EVMAssembly.cpp @@ -19,11 +19,10 @@ */ #include +#include #include -#include - using namespace std; using namespace dev; using namespace dev::eth; @@ -65,7 +64,7 @@ void EVMAssembly::appendLabel(LabelID _labelId) void EVMAssembly::appendLabelReference(LabelID _labelId) { - solAssert(!m_evm15, "Cannot use plain label references in EMV1.5 mode."); + yulAssert(!m_evm15, "Cannot use plain label references in EMV1.5 mode."); // @TODO we now always use labelReferenceSize for all labels, it could be shortened // for some of them. appendInstruction(dev::eth::pushInstruction(labelReferenceSize)); @@ -81,7 +80,7 @@ EVMAssembly::LabelID EVMAssembly::newLabelId() AbstractAssembly::LabelID EVMAssembly::namedLabel(string const& _name) { - solAssert(!_name.empty(), ""); + yulAssert(!_name.empty(), ""); if (!m_namedLabels.count(_name)) m_namedLabels[_name] = newLabelId(); return m_namedLabels[_name]; @@ -89,12 +88,12 @@ AbstractAssembly::LabelID EVMAssembly::namedLabel(string const& _name) void EVMAssembly::appendLinkerSymbol(string const&) { - solAssert(false, "Linker symbols not yet implemented."); + yulAssert(false, "Linker symbols not yet implemented."); } void EVMAssembly::appendJump(int _stackDiffAfter) { - solAssert(!m_evm15, "Plain JUMP used for EVM 1.5"); + yulAssert(!m_evm15, "Plain JUMP used for EVM 1.5"); appendInstruction(dev::eth::Instruction::JUMP); m_stackHeight += _stackDiffAfter; } @@ -131,8 +130,8 @@ void EVMAssembly::appendJumpToIf(LabelID _labelId) void EVMAssembly::appendBeginsub(LabelID _labelId, int _arguments) { - solAssert(m_evm15, "BEGINSUB used for EVM 1.0"); - solAssert(_arguments >= 0, ""); + yulAssert(m_evm15, "BEGINSUB used for EVM 1.0"); + yulAssert(_arguments >= 0, ""); setLabelToCurrentPosition(_labelId); m_bytecode.push_back(uint8_t(dev::eth::Instruction::BEGINSUB)); m_stackHeight += _arguments; @@ -140,8 +139,8 @@ void EVMAssembly::appendBeginsub(LabelID _labelId, int _arguments) void EVMAssembly::appendJumpsub(LabelID _labelId, int _arguments, int _returns) { - solAssert(m_evm15, "JUMPSUB used for EVM 1.0"); - solAssert(_arguments >= 0 && _returns >= 0, ""); + yulAssert(m_evm15, "JUMPSUB used for EVM 1.0"); + yulAssert(_arguments >= 0 && _returns >= 0, ""); m_bytecode.push_back(uint8_t(dev::eth::Instruction::JUMPSUB)); appendLabelReferenceInternal(_labelId); m_stackHeight += _returns - _arguments; @@ -149,8 +148,8 @@ void EVMAssembly::appendJumpsub(LabelID _labelId, int _arguments, int _returns) void EVMAssembly::appendReturnsub(int _returns, int _stackDiffAfter) { - solAssert(m_evm15, "RETURNSUB used for EVM 1.0"); - solAssert(_returns >= 0, ""); + yulAssert(m_evm15, "RETURNSUB used for EVM 1.0"); + yulAssert(_returns >= 0, ""); m_bytecode.push_back(uint8_t(dev::eth::Instruction::RETURNSUB)); m_stackHeight += _stackDiffAfter - _returns; } @@ -164,9 +163,9 @@ eth::LinkerObject EVMAssembly::finalize() for (auto const& ref: m_labelReferences) { size_t referencePos = ref.first; - solAssert(m_labelPositions.count(ref.second), ""); + yulAssert(m_labelPositions.count(ref.second), ""); size_t labelPos = m_labelPositions.at(ref.second); - solAssert(labelPos != size_t(-1), "Undefined but allocated label used."); + yulAssert(labelPos != size_t(-1), "Undefined but allocated label used."); updateReference(referencePos, labelReferenceSize, u256(labelPos)); } @@ -177,8 +176,8 @@ eth::LinkerObject EVMAssembly::finalize() void EVMAssembly::setLabelToCurrentPosition(LabelID _labelId) { - solAssert(m_labelPositions.count(_labelId), "Label not found."); - solAssert(m_labelPositions[_labelId] == size_t(-1), "Label already set."); + yulAssert(m_labelPositions.count(_labelId), "Label not found."); + yulAssert(m_labelPositions[_labelId] == size_t(-1), "Label already set."); m_labelPositions[_labelId] = m_bytecode.size(); } @@ -197,29 +196,29 @@ void EVMAssembly::appendAssemblySize() pair, AbstractAssembly::SubID> EVMAssembly::createSubAssembly() { - solAssert(false, "Sub assemblies not implemented."); + yulAssert(false, "Sub assemblies not implemented."); return {}; } void EVMAssembly::appendDataOffset(AbstractAssembly::SubID) { - solAssert(false, "Data not implemented."); + yulAssert(false, "Data not implemented."); } void EVMAssembly::appendDataSize(AbstractAssembly::SubID) { - solAssert(false, "Data not implemented."); + yulAssert(false, "Data not implemented."); } AbstractAssembly::SubID EVMAssembly::appendData(bytes const&) { - solAssert(false, "Data not implemented."); + yulAssert(false, "Data not implemented."); } void EVMAssembly::updateReference(size_t pos, size_t size, u256 value) { - solAssert(m_bytecode.size() >= size && pos <= m_bytecode.size() - size, ""); - solAssert(value < (u256(1) << (8 * size)), ""); + yulAssert(m_bytecode.size() >= size && pos <= m_bytecode.size() - size, ""); + yulAssert(value < (u256(1) << (8 * size)), ""); for (size_t i = 0; i < size; i++) m_bytecode[pos + i] = uint8_t((value >> (8 * (size - i - 1))) & 0xff); } diff --git a/libyul/backends/evm/EVMCodeTransform.cpp b/libyul/backends/evm/EVMCodeTransform.cpp index a177c10fb..51b31aae5 100644 --- a/libyul/backends/evm/EVMCodeTransform.cpp +++ b/libyul/backends/evm/EVMCodeTransform.cpp @@ -44,9 +44,9 @@ void VariableReferenceCounter::operator()(FunctionDefinition const& _function) { Scope* originalScope = m_scope; - solAssert(m_info.virtualBlocks.at(&_function), ""); + yulAssert(m_info.virtualBlocks.at(&_function), ""); m_scope = m_info.scopes.at(m_info.virtualBlocks.at(&_function).get()).get(); - solAssert(m_scope, "Variable scope does not exist."); + yulAssert(m_scope, "Variable scope does not exist."); for (auto const& v: _function.returnVariables) increaseRefIfFound(v.name); @@ -131,7 +131,7 @@ void CodeTransform::decreaseReference(YulString, Scope::Variable const& _var) return; unsigned& ref = m_context->variableReferences.at(&_var); - solAssert(ref >= 1, ""); + yulAssert(ref >= 1, ""); --ref; if (ref == 0) m_variablesScheduledForDeletion.insert(&_var); @@ -157,7 +157,7 @@ void CodeTransform::freeUnusedVariables() while (m_unusedStackSlots.count(m_assembly.stackHeight() - 1)) { - solAssert(m_unusedStackSlots.erase(m_assembly.stackHeight() - 1), ""); + yulAssert(m_unusedStackSlots.erase(m_assembly.stackHeight() - 1), ""); m_assembly.appendInstruction(dev::eth::Instruction::POP); --m_stackAdjustment; } @@ -165,8 +165,8 @@ void CodeTransform::freeUnusedVariables() void CodeTransform::deleteVariable(Scope::Variable const& _var) { - solAssert(m_allowStackOpt, ""); - solAssert(m_context->variableStackHeights.count(&_var) > 0, ""); + yulAssert(m_allowStackOpt, ""); + yulAssert(m_context->variableStackHeights.count(&_var) > 0, ""); m_unusedStackSlots.insert(m_context->variableStackHeights[&_var]); m_context->variableStackHeights.erase(&_var); m_context->variableReferences.erase(&_var); @@ -175,7 +175,7 @@ void CodeTransform::deleteVariable(Scope::Variable const& _var) void CodeTransform::operator()(VariableDeclaration const& _varDecl) { - solAssert(m_scope, ""); + yulAssert(m_scope, ""); int const numVariables = _varDecl.variables.size(); int height = m_assembly.stackHeight(); @@ -261,7 +261,7 @@ void CodeTransform::operator()(ExpressionStatement const& _statement) void CodeTransform::operator()(FunctionCall const& _call) { - solAssert(m_scope, ""); + yulAssert(m_scope, ""); if (BuiltinFunctionForEVM const* builtin = m_dialect.builtin(_call.functionName.name)) { @@ -283,13 +283,13 @@ void CodeTransform::operator()(FunctionCall const& _call) } Scope::Function* function = nullptr; - solAssert(m_scope->lookup(_call.functionName.name, GenericVisitor{ - [=](Scope::Variable&) { solAssert(false, "Expected function name."); }, - [=](Scope::Label&) { solAssert(false, "Expected function name."); }, + yulAssert(m_scope->lookup(_call.functionName.name, GenericVisitor{ + [=](Scope::Variable&) { yulAssert(false, "Expected function name."); }, + [=](Scope::Label&) { yulAssert(false, "Expected function name."); }, [&](Scope::Function& _function) { function = &_function; } }), "Function name not found."); - solAssert(function, ""); - solAssert(function->arguments.size() == _call.arguments.size(), ""); + yulAssert(function, ""); + yulAssert(function->arguments.size() == _call.arguments.size(), ""); for (auto const& arg: _call.arguments | boost::adaptors::reversed) visitExpression(arg); m_assembly.setSourceLocation(_call.location); @@ -309,7 +309,7 @@ void CodeTransform::operator()(Identifier const& _identifier) { m_assembly.setSourceLocation(_identifier.location); // First search internals, then externals. - solAssert(m_scope, ""); + yulAssert(m_scope, ""); if (m_scope->lookup(_identifier.name, GenericVisitor{ [=](Scope::Variable& _var) { @@ -328,13 +328,13 @@ void CodeTransform::operator()(Identifier const& _identifier) }, [=](Scope::Function&) { - solAssert(false, "Function not removed during desugaring."); + yulAssert(false, "Function not removed during desugaring."); } })) { return; } - solAssert( + yulAssert( m_identifierAccess.generateCode, "Identifier not found and no external access available." ); @@ -352,9 +352,9 @@ void CodeTransform::operator()(Literal const& _literal) void CodeTransform::operator()(yul::Instruction const& _instruction) { - solAssert(!m_allowStackOpt, ""); - solAssert(!m_evm15 || _instruction.instruction != dev::eth::Instruction::JUMP, "Bare JUMP instruction used for EVM1.5"); - solAssert(!m_evm15 || _instruction.instruction != dev::eth::Instruction::JUMPI, "Bare JUMPI instruction used for EVM1.5"); + yulAssert(!m_allowStackOpt, ""); + yulAssert(!m_evm15 || _instruction.instruction != dev::eth::Instruction::JUMP, "Bare JUMP instruction used for EVM1.5"); + yulAssert(!m_evm15 || _instruction.instruction != dev::eth::Instruction::JUMPI, "Bare JUMPI instruction used for EVM1.5"); m_assembly.setSourceLocation(_instruction.location); m_assembly.appendInstruction(_instruction.instruction); checkStackHeight(&_instruction); @@ -389,7 +389,7 @@ void CodeTransform::operator()(Switch const& _switch) m_assembly.setSourceLocation(c.location); AbstractAssembly::LabelID bodyLabel = m_assembly.newLabelId(); caseBodies[&c] = bodyLabel; - solAssert(m_assembly.stackHeight() == expressionHeight + 1, ""); + yulAssert(m_assembly.stackHeight() == expressionHeight + 1, ""); m_assembly.appendInstruction(dev::eth::dupInstruction(2)); m_assembly.appendInstruction(dev::eth::Instruction::EQ); m_assembly.appendJumpToIf(bodyLabel); @@ -423,15 +423,15 @@ void CodeTransform::operator()(Switch const& _switch) void CodeTransform::operator()(FunctionDefinition const& _function) { - solAssert(m_scope, ""); - solAssert(m_scope->identifiers.count(_function.name), ""); + yulAssert(m_scope, ""); + yulAssert(m_scope->identifiers.count(_function.name), ""); Scope::Function& function = std::get(m_scope->identifiers.at(_function.name)); int const localStackAdjustment = m_evm15 ? 0 : 1; int height = localStackAdjustment; - solAssert(m_info.scopes.at(&_function.body), ""); + yulAssert(m_info.scopes.at(&_function.body), ""); Scope* varScope = m_info.scopes.at(m_info.virtualBlocks.at(&_function).get()).get(); - solAssert(varScope, ""); + yulAssert(varScope, ""); for (auto const& v: _function.parameters | boost::adaptors::reversed) { auto& var = std::get(varScope->identifiers.at(v.name)); @@ -535,7 +535,7 @@ void CodeTransform::operator()(FunctionDefinition const& _function) swap(stackLayout[stackLayout.back()], stackLayout.back()); } for (int i = 0; size_t(i) < stackLayout.size(); ++i) - solAssert(i == stackLayout[i], "Error reshuffling stack."); + yulAssert(i == stackLayout[i], "Error reshuffling stack."); } } if (m_evm15) @@ -647,15 +647,15 @@ AbstractAssembly::LabelID CodeTransform::labelFromIdentifier(Identifier const& _ { AbstractAssembly::LabelID label = AbstractAssembly::LabelID(-1); if (!m_scope->lookup(_identifier.name, GenericVisitor{ - [=](Scope::Variable&) { solAssert(false, "Expected label"); }, + [=](Scope::Variable&) { yulAssert(false, "Expected label"); }, [&](Scope::Label& _label) { label = labelID(_label); }, - [=](Scope::Function&) { solAssert(false, "Expected label"); } + [=](Scope::Function&) { yulAssert(false, "Expected label"); } })) { - solAssert(false, "Identifier not found."); + yulAssert(false, "Identifier not found."); } return label; } @@ -723,15 +723,15 @@ void CodeTransform::finalizeBlock(Block const& _block, int blockStartStackHeight freeUnusedVariables(); // pop variables - solAssert(m_info.scopes.at(&_block).get() == m_scope, ""); + yulAssert(m_info.scopes.at(&_block).get() == m_scope, ""); for (auto const& id: m_scope->identifiers) if (holds_alternative(id.second)) { Scope::Variable const& var = std::get(id.second); if (m_allowStackOpt) { - solAssert(!m_context->variableStackHeights.count(&var), ""); - solAssert(!m_context->variableReferences.count(&var), ""); + yulAssert(!m_context->variableStackHeights.count(&var), ""); + yulAssert(!m_context->variableReferences.count(&var), ""); m_stackAdjustment++; } else @@ -739,20 +739,20 @@ void CodeTransform::finalizeBlock(Block const& _block, int blockStartStackHeight } int deposit = m_assembly.stackHeight() - blockStartStackHeight; - solAssert(deposit == 0, "Invalid stack height at end of block: " + to_string(deposit)); + yulAssert(deposit == 0, "Invalid stack height at end of block: " + to_string(deposit)); checkStackHeight(&_block); } void CodeTransform::generateMultiAssignment(vector const& _variableNames) { - solAssert(m_scope, ""); + yulAssert(m_scope, ""); for (auto const& variableName: _variableNames | boost::adaptors::reversed) generateAssignment(variableName); } void CodeTransform::generateAssignment(Identifier const& _variableName) { - solAssert(m_scope, ""); + yulAssert(m_scope, ""); if (auto var = m_scope->lookup(_variableName.name)) { Scope::Variable const& _var = std::get(*var); @@ -763,7 +763,7 @@ void CodeTransform::generateAssignment(Identifier const& _variableName) } else { - solAssert( + yulAssert( m_identifierAccess.generateCode, "Identifier not found and no external access available." ); @@ -773,9 +773,9 @@ void CodeTransform::generateAssignment(Identifier const& _variableName) int CodeTransform::variableHeightDiff(Scope::Variable const& _var, YulString _varName, bool _forSwap) { - solAssert(m_context->variableStackHeights.count(&_var), ""); + yulAssert(m_context->variableStackHeights.count(&_var), ""); int heightDiff = m_assembly.stackHeight() - m_context->variableStackHeights[&_var]; - solAssert(heightDiff > (_forSwap ? 1 : 0), "Negative stack difference for variable."); + yulAssert(heightDiff > (_forSwap ? 1 : 0), "Negative stack difference for variable."); int limit = _forSwap ? 17 : 16; if (heightDiff > limit) { @@ -794,15 +794,15 @@ int CodeTransform::variableHeightDiff(Scope::Variable const& _var, YulString _va void CodeTransform::expectDeposit(int _deposit, int _oldHeight) const { - solAssert(m_assembly.stackHeight() == _oldHeight + _deposit, "Invalid stack deposit."); + yulAssert(m_assembly.stackHeight() == _oldHeight + _deposit, "Invalid stack deposit."); } void CodeTransform::checkStackHeight(void const* _astElement) const { - solAssert(m_info.stackHeightInfo.count(_astElement), "Stack height for AST element not found."); + yulAssert(m_info.stackHeightInfo.count(_astElement), "Stack height for AST element not found."); int stackHeightInAnalysis = m_info.stackHeightInfo.at(_astElement); int stackHeightInCodegen = m_assembly.stackHeight() - m_stackAdjustment; - solAssert( + yulAssert( stackHeightInAnalysis == stackHeightInCodegen, "Stack height mismatch between analysis and code generation phase: Analysis: " + to_string(stackHeightInAnalysis) + diff --git a/libyul/backends/evm/NoOutputAssembly.cpp b/libyul/backends/evm/NoOutputAssembly.cpp index 4618d4e54..e2a34ef20 100644 --- a/libyul/backends/evm/NoOutputAssembly.cpp +++ b/libyul/backends/evm/NoOutputAssembly.cpp @@ -19,11 +19,10 @@ */ #include +#include #include -#include - using namespace std; using namespace dev; using namespace langutil; @@ -47,7 +46,7 @@ void NoOutputAssembly::appendLabel(LabelID) void NoOutputAssembly::appendLabelReference(LabelID) { - solAssert(!m_evm15, "Cannot use plain label references in EMV1.5 mode."); + yulAssert(!m_evm15, "Cannot use plain label references in EMV1.5 mode."); appendInstruction(dev::eth::pushInstruction(1)); } @@ -63,12 +62,12 @@ AbstractAssembly::LabelID NoOutputAssembly::namedLabel(string const&) void NoOutputAssembly::appendLinkerSymbol(string const&) { - solAssert(false, "Linker symbols not yet implemented."); + yulAssert(false, "Linker symbols not yet implemented."); } void NoOutputAssembly::appendJump(int _stackDiffAfter) { - solAssert(!m_evm15, "Plain JUMP used for EVM 1.5"); + yulAssert(!m_evm15, "Plain JUMP used for EVM 1.5"); appendInstruction(dev::eth::Instruction::JUMP); m_stackHeight += _stackDiffAfter; } @@ -97,22 +96,22 @@ void NoOutputAssembly::appendJumpToIf(LabelID _labelId) void NoOutputAssembly::appendBeginsub(LabelID, int _arguments) { - solAssert(m_evm15, "BEGINSUB used for EVM 1.0"); - solAssert(_arguments >= 0, ""); + yulAssert(m_evm15, "BEGINSUB used for EVM 1.0"); + yulAssert(_arguments >= 0, ""); m_stackHeight += _arguments; } void NoOutputAssembly::appendJumpsub(LabelID, int _arguments, int _returns) { - solAssert(m_evm15, "JUMPSUB used for EVM 1.0"); - solAssert(_arguments >= 0 && _returns >= 0, ""); + yulAssert(m_evm15, "JUMPSUB used for EVM 1.0"); + yulAssert(_arguments >= 0 && _returns >= 0, ""); m_stackHeight += _returns - _arguments; } void NoOutputAssembly::appendReturnsub(int _returns, int _stackDiffAfter) { - solAssert(m_evm15, "RETURNSUB used for EVM 1.0"); - solAssert(_returns >= 0, ""); + yulAssert(m_evm15, "RETURNSUB used for EVM 1.0"); + yulAssert(_returns >= 0, ""); m_stackHeight += _stackDiffAfter - _returns; } @@ -123,7 +122,7 @@ void NoOutputAssembly::appendAssemblySize() pair, AbstractAssembly::SubID> NoOutputAssembly::createSubAssembly() { - solAssert(false, "Sub assemblies not implemented."); + yulAssert(false, "Sub assemblies not implemented."); return {}; } diff --git a/scripts/deps-ppa/static_z3.sh b/scripts/deps-ppa/static_z3.sh index 9f39a79c9..b38af9e9c 100755 --- a/scripts/deps-ppa/static_z3.sh +++ b/scripts/deps-ppa/static_z3.sh @@ -25,7 +25,9 @@ set -ev keyid=70D110489D66E2F6 email=builds@ethereum.org packagename=libz3-static-dev -version=4.8.6 +# On the next version the git cherry-pick below should be removed and the patch suffix removed from the version string. +version=4.8.7 +version_patchsuffix=-1 DISTRIBUTIONS="bionic disco eoan" @@ -40,11 +42,14 @@ pparepo=cpp-build-deps ppafilesurl=https://launchpad.net/~ethereum/+archive/ubuntu/${pparepo}/+files # Fetch source -git clone --depth 1 --branch z3-${version} https://github.com/Z3Prover/z3.git +git clone --branch z3-${version} https://github.com/Z3Prover/z3.git cd z3 -debversion="$version" +# Patch build failure. +git cherry-pick e212159f4e -CMAKE_OPTIONS="-DBUILD_LIBZ3_SHARED=OFF -DCMAKE_BUILD_TYPE=Release" +debversion="${version}${version_patchsuffix}" + +CMAKE_OPTIONS="-DZ3_BUILD_LIBZ3_SHARED=OFF -DCMAKE_BUILD_TYPE=Release" # gzip will create different tars all the time and we are not allowed # to upload the same file twice with different contents, so we only @@ -176,7 +181,7 @@ This program is free software: you can redistribute it and/or modify Public License version 3 can be found in "/usr/share/common-licenses/GPL-3". EOF cat < debian/changelog -libz3-static-dev (0.0.1-0ubuntu1) saucy; urgency=low +libz3-static-dev (0.0.1-2ubuntu0) saucy; urgency=low * Initial release. @@ -186,7 +191,7 @@ mkdir debian/source echo "3.0 (quilt)" > debian/source/format chmod +x debian/rules -versionsuffix=0ubuntu1~${distribution} +versionsuffix=2ubuntu0~${distribution} EMAIL="$email" dch -v 1:${debversion}-${versionsuffix} "build of ${version}" # build source package diff --git a/scripts/install_static_z3.sh b/scripts/install_static_z3.sh index 7748fb1f3..6fba203d8 100644 --- a/scripts/install_static_z3.sh +++ b/scripts/install_static_z3.sh @@ -1,9 +1,9 @@ #!/usr/bin/env bash -git clone --depth 1 --branch z3-4.8.1 https://github.com/Z3Prover/z3.git +git clone --depth 1 --branch z3-4.8.7 https://github.com/Z3Prover/z3.git cd z3 mkdir build cd build -LDFLAGS="-static" cmake -DBUILD_LIBZ3_SHARED=OFF .. +LDFLAGS="-static" cmake -DZ3_BUILD_LIBZ3_SHARED=OFF .. make -j 4 make install \ No newline at end of file diff --git a/test/libdevcore/JSON.cpp b/test/libdevcore/JSON.cpp index a3e081be6..684fd92b2 100644 --- a/test/libdevcore/JSON.cpp +++ b/test/libdevcore/JSON.cpp @@ -69,47 +69,6 @@ BOOST_AUTO_TEST_CASE(json_compact_print) BOOST_CHECK("{\"1\":1,\"2\":\"2\",\"3\":{\"3.1\":\"3.1\",\"3.2\":2}}" == jsonCompactPrint(json)); } -BOOST_AUTO_TEST_CASE(parse_json_not_strict) -{ - Json::Value json; - std::string errors; - - // just parse a valid json input - BOOST_CHECK(jsonParse("{\"1\":1,\"2\":\"2\",\"3\":{\"3.1\":\"3.1\",\"3.2\":2}}", json, &errors)); - BOOST_CHECK(json["1"] == 1); - BOOST_CHECK(json["2"] == "2"); - BOOST_CHECK(json["3"]["3.1"] == "3.1"); - BOOST_CHECK(json["3"]["3.2"] == 2); - - // trailing garbage is allowed here - BOOST_CHECK(jsonParse("{\"1\":2,\"2\":\"2\",\"3\":{\"3.1\":\"3.1\",\"3.2\":3}}}}}}}}}}", json, &errors)); - BOOST_CHECK(json["1"] == 2); - BOOST_CHECK(json["2"] == "2"); - BOOST_CHECK(json["3"]["3.1"] == "3.1"); - BOOST_CHECK(json["3"]["3.2"] == 3); - - // comments are allowed - BOOST_CHECK(jsonParse( - "{\"1\":3, // awesome comment\n\"2\":\"2\",\"3\":{\"3.1\":\"3.1\",\"3.2\":4}}", json, &errors - )); - BOOST_CHECK(json["1"] == 3); - BOOST_CHECK(json["2"] == "2"); - BOOST_CHECK(json["3"]["3.1"] == "3.1"); - BOOST_CHECK(json["3"]["3.2"] == 4); - - // root element other than object or array is allowed - BOOST_CHECK(jsonParse("[]", json, &errors)); - BOOST_CHECK(jsonParse("{}", json, &errors)); - BOOST_CHECK(jsonParse("1", json, &errors)); - BOOST_CHECK(json == 1); - BOOST_CHECK(jsonParse("\"hello\"", json, &errors)); - BOOST_CHECK(json == "hello"); - - // non-UTF-8 escapes allowed - BOOST_CHECK(jsonParse("[ \"\x80\xec\x80\" ]", json, &errors)); - BOOST_CHECK(json[0] == "\x80\xec\x80"); -} - BOOST_AUTO_TEST_CASE(parse_json_strict) { Json::Value json; diff --git a/test/libsolidity/Metadata.cpp b/test/libsolidity/Metadata.cpp index 67e44e8d7..e8da61704 100644 --- a/test/libsolidity/Metadata.cpp +++ b/test/libsolidity/Metadata.cpp @@ -268,7 +268,7 @@ BOOST_AUTO_TEST_CASE(metadata_useLiteralContent) BOOST_REQUIRE_MESSAGE(compilerStack.compile(), "Compiling contract failed"); string metadata_str = compilerStack.metadata("test"); Json::Value metadata; - jsonParse(metadata_str, metadata); + jsonParseStrict(metadata_str, metadata); BOOST_CHECK(dev::test::isValidMetadata(metadata_str)); BOOST_CHECK(metadata.isMember("settings")); BOOST_CHECK(metadata["settings"].isMember("metadata")); diff --git a/test/libsolidity/SMTCheckerJSONTest.cpp b/test/libsolidity/SMTCheckerJSONTest.cpp index a2ce4e26b..19bdcaacc 100644 --- a/test/libsolidity/SMTCheckerJSONTest.cpp +++ b/test/libsolidity/SMTCheckerJSONTest.cpp @@ -18,6 +18,7 @@ #include #include #include +#include #include #include #include @@ -43,7 +44,7 @@ SMTCheckerTest::SMTCheckerTest(string const& _filename, langutil::EVMVersion _ev string jsonFilename = _filename.substr(0, _filename.size() - 4) + ".json"; if ( - !jsonParseFile(jsonFilename, m_smtResponses) || + !jsonParseStrict(readFileAsString(jsonFilename), m_smtResponses) || !m_smtResponses.isObject() ) BOOST_THROW_EXCEPTION(runtime_error("Invalid JSON file.")); @@ -158,7 +159,7 @@ Json::Value SMTCheckerTest::buildJson(string const& _extra) sources += "}"; string input = "{" + language + ", " + sources + "}"; Json::Value source; - if (!jsonParse(input, source)) + if (!jsonParseStrict(input, source)) BOOST_THROW_EXCEPTION(runtime_error("Could not build JSON from string: " + input)); return source; } diff --git a/test/libsolidity/StandardCompiler.cpp b/test/libsolidity/StandardCompiler.cpp index c3a4badee..edf0cdc07 100644 --- a/test/libsolidity/StandardCompiler.cpp +++ b/test/libsolidity/StandardCompiler.cpp @@ -1199,7 +1199,9 @@ BOOST_AUTO_TEST_CASE(use_stack_optimization) result = compiler.compile(parsedInput); BOOST_REQUIRE(result["errors"].isArray()); BOOST_CHECK(result["errors"][0]["severity"] == "error"); - BOOST_CHECK(result["errors"][0]["type"] == "InternalCompilerError"); + BOOST_REQUIRE(result["errors"][0]["message"].isString()); + BOOST_CHECK(result["errors"][0]["message"].asString().find("Stack too deep when compiling inline assembly") != std::string::npos); + BOOST_CHECK(result["errors"][0]["type"] == "YulException"); } BOOST_AUTO_TEST_CASE(standard_output_selection_wildcard) diff --git a/test/libsolidity/smtCheckerTests/special/abi_decode_memory_v2.sol b/test/libsolidity/smtCheckerTests/special/abi_decode_memory_v2.sol index c20780065..a38c93e6f 100644 --- a/test/libsolidity/smtCheckerTests/special/abi_decode_memory_v2.sol +++ b/test/libsolidity/smtCheckerTests/special/abi_decode_memory_v2.sol @@ -12,6 +12,5 @@ contract C { // Warning: (206-209): Assertion checker does not yet implement type abi // Warning: (225-226): Assertion checker does not yet implement type type(struct C.S storage pointer) // Warning: (235-241): Assertion checker does not yet implement type type(uint256[] memory) -// Warning: (235-241): Assertion checker does not yet implement this expression. // Warning: (235-244): Assertion checker does not yet implement type type(uint256[] memory[2] memory) // Warning: (206-246): Assertion checker does not yet implement this type of function call. diff --git a/test/libsolidity/smtCheckerTests/types/no_effect_statements.sol b/test/libsolidity/smtCheckerTests/types/no_effect_statements.sol new file mode 100644 index 000000000..f4d1299e9 --- /dev/null +++ b/test/libsolidity/smtCheckerTests/types/no_effect_statements.sol @@ -0,0 +1,24 @@ +pragma experimental SMTChecker; +contract test { + struct s { uint a; uint b;} + function f() pure public returns (byte) { + s; + s(1,2); + s[7]; + uint; + uint[7]; + } +} +// ---- +// Warning: (125-126): Statement has no effect. +// Warning: (130-136): Statement has no effect. +// Warning: (140-144): Statement has no effect. +// Warning: (148-152): Statement has no effect. +// Warning: (156-163): Statement has no effect. +// Warning: (125-126): Assertion checker does not yet implement type type(struct test.s storage pointer) +// Warning: (130-131): Assertion checker does not yet implement type type(struct test.s storage pointer) +// Warning: (130-136): Assertion checker does not yet implement type struct test.s memory +// Warning: (130-136): Assertion checker does not yet implement this expression. +// Warning: (140-141): Assertion checker does not yet implement type type(struct test.s storage pointer) +// Warning: (140-144): Assertion checker does not yet implement type type(struct test.s memory[7] memory) +// Warning: (156-163): Assertion checker does not yet implement type type(uint256[7] memory) diff --git a/test/libsolidity/smtCheckerTests/types/type_expression_array_2d.sol b/test/libsolidity/smtCheckerTests/types/type_expression_array_2d.sol index f63e6aef3..2bd64030d 100644 --- a/test/libsolidity/smtCheckerTests/types/type_expression_array_2d.sol +++ b/test/libsolidity/smtCheckerTests/types/type_expression_array_2d.sol @@ -7,5 +7,4 @@ function f() public pure { int[][]; } // ---- // Warning: (73-80): Statement has no effect. // Warning: (73-78): Assertion checker does not yet implement type type(int256[] memory) -// Warning: (73-78): Assertion checker does not yet implement this expression. // Warning: (73-80): Assertion checker does not yet implement type type(int256[] memory[] memory) diff --git a/test/libsolidity/smtCheckerTests/types/type_expression_array_3d.sol b/test/libsolidity/smtCheckerTests/types/type_expression_array_3d.sol index 2588ee98d..3f0967caf 100644 --- a/test/libsolidity/smtCheckerTests/types/type_expression_array_3d.sol +++ b/test/libsolidity/smtCheckerTests/types/type_expression_array_3d.sol @@ -7,6 +7,5 @@ function f() public pure { int[][][]; } // ---- // Warning: (73-82): Statement has no effect. // Warning: (73-78): Assertion checker does not yet implement type type(int256[] memory) -// Warning: (73-78): Assertion checker does not yet implement this expression. // Warning: (73-80): Assertion checker does not yet implement type type(int256[] memory[] memory) // Warning: (73-82): Assertion checker does not yet implement type type(int256[] memory[] memory[] memory) diff --git a/test/libsolidity/smtCheckerTests/types/type_expression_tuple_array_2d.sol b/test/libsolidity/smtCheckerTests/types/type_expression_tuple_array_2d.sol index 02c2ac056..e648b5d6d 100644 --- a/test/libsolidity/smtCheckerTests/types/type_expression_tuple_array_2d.sol +++ b/test/libsolidity/smtCheckerTests/types/type_expression_tuple_array_2d.sol @@ -7,6 +7,5 @@ function f() public pure { (int[][]); } // ---- // Warning: (73-82): Statement has no effect. // Warning: (74-79): Assertion checker does not yet implement type type(int256[] memory) -// Warning: (74-79): Assertion checker does not yet implement this expression. // Warning: (74-81): Assertion checker does not yet implement type type(int256[] memory[] memory) // Warning: (73-82): Assertion checker does not yet implement type type(int256[] memory[] memory) diff --git a/test/libsolidity/smtCheckerTests/types/type_expression_tuple_array_3d.sol b/test/libsolidity/smtCheckerTests/types/type_expression_tuple_array_3d.sol index 893f30581..2d66a3bb2 100644 --- a/test/libsolidity/smtCheckerTests/types/type_expression_tuple_array_3d.sol +++ b/test/libsolidity/smtCheckerTests/types/type_expression_tuple_array_3d.sol @@ -7,7 +7,6 @@ function f() public pure { (int[][][]); } // ---- // Warning: (73-84): Statement has no effect. // Warning: (74-79): Assertion checker does not yet implement type type(int256[] memory) -// Warning: (74-79): Assertion checker does not yet implement this expression. // Warning: (74-81): Assertion checker does not yet implement type type(int256[] memory[] memory) // Warning: (74-83): Assertion checker does not yet implement type type(int256[] memory[] memory[] memory) // Warning: (73-84): Assertion checker does not yet implement type type(int256[] memory[] memory[] memory)