From 53d0684cb4dc7d7b5c9e92bf9e77383e14ecec8c Mon Sep 17 00:00:00 2001 From: LianaHus Date: Thu, 1 Oct 2015 17:59:01 +0200 Subject: -fixed the warning printing -style fixes --- libsolidity/CompilerStack.cpp | 9 +++++---- libsolidity/TypeChecker.cpp | 2 +- solc/CommandLineInterface.cpp | 17 ++++++++--------- test/libsolidity/SolidityNameAndTypeResolution.cpp | 6 +++--- 4 files changed, 17 insertions(+), 17 deletions(-) diff --git a/libsolidity/CompilerStack.cpp b/libsolidity/CompilerStack.cpp index e6b87264..6ee19d58 100644 --- a/libsolidity/CompilerStack.cpp +++ b/libsolidity/CompilerStack.cpp @@ -122,6 +122,7 @@ bool CompilerStack::parse() } InterfaceHandler interfaceHandler; + bool typesFine = true; for (Source const* source: m_sourceOrder) for (ASTPointer const& node: source->ast->nodes()) if (ContractDefinition* contract = dynamic_cast(node.get())) @@ -129,14 +130,14 @@ bool CompilerStack::parse() m_globalContext->setCurrentContract(*contract); resolver.updateDeclaration(*m_globalContext->currentThis()); TypeChecker typeChecker; - bool typesFine = typeChecker.checkTypeRequirements(*contract); - if (!typesFine) - m_errors += typeChecker.errors(); + if (!typeChecker.checkTypeRequirements(*contract)) + typesFine = false; + m_errors += typeChecker.errors(); contract->setDevDocumentation(interfaceHandler.devDocumentation(*contract)); contract->setUserDocumentation(interfaceHandler.userDocumentation(*contract)); m_contracts[contract->name()].contract = contract; } - m_parseSuccessful = m_errors.empty(); + m_parseSuccessful = typesFine; return m_parseSuccessful; } diff --git a/libsolidity/TypeChecker.cpp b/libsolidity/TypeChecker.cpp index ec60373c..48a8a536 100644 --- a/libsolidity/TypeChecker.cpp +++ b/libsolidity/TypeChecker.cpp @@ -43,7 +43,7 @@ bool TypeChecker::checkTypeRequirements(const ContractDefinition& _contract) if (m_errors.empty()) throw; // Something is weird here, rather throw again. } - bool success = m_errors.empty(); + bool success = true; for (auto const& it: m_errors) if (!dynamic_cast(it.get())) { diff --git a/solc/CommandLineInterface.cpp b/solc/CommandLineInterface.cpp index e3c7620e..be10faa8 100644 --- a/solc/CommandLineInterface.cpp +++ b/solc/CommandLineInterface.cpp @@ -491,16 +491,15 @@ bool CommandLineInterface::processInput() // TODO: Perhaps we should not compile unless requested bool optimize = m_args.count("optimize") > 0; unsigned runs = m_args["optimize-runs"].as(); - if (!m_compiler->compile(optimize, runs)) - { - for (auto const& error: m_compiler->errors()) - SourceReferenceFormatter::printExceptionInformation( - cerr, - *error, - (dynamic_pointer_cast(error)) ? "Warning" : "Error", *m_compiler - ); + bool successful = m_compiler->compile(optimize, runs); + for (auto const& error: m_compiler->errors()) + SourceReferenceFormatter::printExceptionInformation( + cerr, + *error, + (dynamic_pointer_cast(error)) ? "Warning" : "Error", *m_compiler + ); + if (!successful) return false; - } m_compiler->link(m_libraries); } catch (ParserError const& _exception) diff --git a/test/libsolidity/SolidityNameAndTypeResolution.cpp b/test/libsolidity/SolidityNameAndTypeResolution.cpp index ad7b59ce..961c10b4 100644 --- a/test/libsolidity/SolidityNameAndTypeResolution.cpp +++ b/test/libsolidity/SolidityNameAndTypeResolution.cpp @@ -45,7 +45,7 @@ namespace { pair, shared_ptr> -parseAnalyseAndReturnError(string const& _source, bool _warning = false) +parseAnalyseAndReturnError(string const& _source, bool _reportWarnings = false) { Parser parser; ASTPointer sourceUnit; @@ -76,12 +76,12 @@ parseAnalyseAndReturnError(string const& _source, bool _warning = false) { for (auto const& firstError: typeChecker.errors()) { - if (!dynamic_pointer_cast(firstError)) + if (_reportWarnings || !dynamic_pointer_cast(firstError)) { err = firstError; break; } - else if (_warning) + else if (_reportWarnings) { err = firstError; break; -- cgit