From 63060fc1f0f2f27ab4ad853c7295c2cfba373b83 Mon Sep 17 00:00:00 2001 From: LianaHus Date: Fri, 6 Nov 2015 18:43:17 +0100 Subject: fixed test framework --- libsolidity/analysis/NameAndTypeResolver.cpp | 9 ------ libsolidity/analysis/ReferencesResolver.h | 9 +++++- test/libsolidity/SolidityNameAndTypeResolution.cpp | 37 ++++++++++++---------- 3 files changed, 28 insertions(+), 27 deletions(-) diff --git a/libsolidity/analysis/NameAndTypeResolver.cpp b/libsolidity/analysis/NameAndTypeResolver.cpp index d681b99b..85944e0f 100644 --- a/libsolidity/analysis/NameAndTypeResolver.cpp +++ b/libsolidity/analysis/NameAndTypeResolver.cpp @@ -84,9 +84,6 @@ bool NameAndTypeResolver::resolveNamesAndTypes(ContractDefinition& _contract) importInheritedScope(*base); } - if (!success) - return false; - for (ASTPointer const& structDef: _contract.definedStructs()) if (!resolver.resolve(*structDef)) success = false; @@ -100,8 +97,6 @@ bool NameAndTypeResolver::resolveNamesAndTypes(ContractDefinition& _contract) if (!resolver.resolve(*event)) success = false; // these can contain code, only resolve parameters for now - if (!success) - return false; for (ASTPointer const& modifier: _contract.functionModifiers()) { m_currentScope = &m_scopes[modifier.get()]; @@ -110,8 +105,6 @@ bool NameAndTypeResolver::resolveNamesAndTypes(ContractDefinition& _contract) success = false; } - if (!success) - return false; for (ASTPointer const& function: _contract.definedFunctions()) { m_currentScope = &m_scopes[function.get()]; @@ -138,8 +131,6 @@ bool NameAndTypeResolver::resolveNamesAndTypes(ContractDefinition& _contract) success = false; } - if (!success) - return false; for (ASTPointer const& function: _contract.definedFunctions()) { m_currentScope = &m_scopes[function.get()]; diff --git a/libsolidity/analysis/ReferencesResolver.h b/libsolidity/analysis/ReferencesResolver.h index 237d01a0..be618f23 100644 --- a/libsolidity/analysis/ReferencesResolver.h +++ b/libsolidity/analysis/ReferencesResolver.h @@ -59,7 +59,14 @@ public: /// @returns true if no errors during resolving bool resolve(ASTNode& _root) { - _root.accept(*this); + try + { + _root.accept(*this); + } + catch (FatalError const& e) + { + solAssert(m_errorOccurred, ""); + } return !m_errorOccurred; } diff --git a/test/libsolidity/SolidityNameAndTypeResolution.cpp b/test/libsolidity/SolidityNameAndTypeResolution.cpp index 6b36f4cc..f4e01000 100644 --- a/test/libsolidity/SolidityNameAndTypeResolution.cpp +++ b/test/libsolidity/SolidityNameAndTypeResolution.cpp @@ -62,33 +62,36 @@ parseAnalyseAndReturnError(string const& _source, bool _reportWarnings = false) solAssert(Error::containsOnlyWarnings(errors), ""); resolver.registerDeclarations(*sourceUnit); + bool success = true; for (ASTPointer const& node: sourceUnit->nodes()) if (ContractDefinition* contract = dynamic_cast(node.get())) { globalContext->setCurrentContract(*contract); resolver.updateDeclaration(*globalContext->currentThis()); resolver.updateDeclaration(*globalContext->currentSuper()); - resolver.resolveNamesAndTypes(*contract); + if (! resolver.resolveNamesAndTypes(*contract)) + success = false; } - for (ASTPointer const& node: sourceUnit->nodes()) - if (ContractDefinition* contract = dynamic_cast(node.get())) - { - globalContext->setCurrentContract(*contract); - resolver.updateDeclaration(*globalContext->currentThis()); + if (success) + for (ASTPointer const& node: sourceUnit->nodes()) + if (ContractDefinition* contract = dynamic_cast(node.get())) + { + globalContext->setCurrentContract(*contract); + resolver.updateDeclaration(*globalContext->currentThis()); - TypeChecker typeChecker(errors); - bool success = typeChecker.checkTypeRequirements(*contract); - BOOST_CHECK(success || !errors.empty()); + TypeChecker typeChecker(errors); + bool success = typeChecker.checkTypeRequirements(*contract); + BOOST_CHECK(success || !errors.empty()); - for (auto const& currentError: errors) - { - if ( - (_reportWarnings && currentError->type() == Error::Type::Warning) || - (!_reportWarnings && currentError->type() != Error::Type::Warning) - ) - return make_pair(sourceUnit, std::make_shared(currentError->type())); } - } + for (auto const& currentError: errors) + { + if ( + (_reportWarnings && currentError->type() == Error::Type::Warning) || + (!_reportWarnings && currentError->type() != Error::Type::Warning) + ) + return make_pair(sourceUnit, std::make_shared(currentError->type())); + } } catch(Error const& _e) { -- cgit