-fixed the warning printing

-style fixes
This commit is contained in:
LianaHus 2015-10-01 17:59:01 +02:00
parent 2706846f43
commit 53d0684cb4
4 changed files with 17 additions and 17 deletions

View File

@ -122,6 +122,7 @@ bool CompilerStack::parse()
} }
InterfaceHandler interfaceHandler; InterfaceHandler interfaceHandler;
bool typesFine = true;
for (Source const* source: m_sourceOrder) for (Source const* source: m_sourceOrder)
for (ASTPointer<ASTNode> const& node: source->ast->nodes()) for (ASTPointer<ASTNode> const& node: source->ast->nodes())
if (ContractDefinition* contract = dynamic_cast<ContractDefinition*>(node.get())) if (ContractDefinition* contract = dynamic_cast<ContractDefinition*>(node.get()))
@ -129,14 +130,14 @@ bool CompilerStack::parse()
m_globalContext->setCurrentContract(*contract); m_globalContext->setCurrentContract(*contract);
resolver.updateDeclaration(*m_globalContext->currentThis()); resolver.updateDeclaration(*m_globalContext->currentThis());
TypeChecker typeChecker; TypeChecker typeChecker;
bool typesFine = typeChecker.checkTypeRequirements(*contract); if (!typeChecker.checkTypeRequirements(*contract))
if (!typesFine) typesFine = false;
m_errors += typeChecker.errors(); m_errors += typeChecker.errors();
contract->setDevDocumentation(interfaceHandler.devDocumentation(*contract)); contract->setDevDocumentation(interfaceHandler.devDocumentation(*contract));
contract->setUserDocumentation(interfaceHandler.userDocumentation(*contract)); contract->setUserDocumentation(interfaceHandler.userDocumentation(*contract));
m_contracts[contract->name()].contract = contract; m_contracts[contract->name()].contract = contract;
} }
m_parseSuccessful = m_errors.empty(); m_parseSuccessful = typesFine;
return m_parseSuccessful; return m_parseSuccessful;
} }

View File

@ -43,7 +43,7 @@ bool TypeChecker::checkTypeRequirements(const ContractDefinition& _contract)
if (m_errors.empty()) if (m_errors.empty())
throw; // Something is weird here, rather throw again. throw; // Something is weird here, rather throw again.
} }
bool success = m_errors.empty(); bool success = true;
for (auto const& it: m_errors) for (auto const& it: m_errors)
if (!dynamic_cast<Warning const*>(it.get())) if (!dynamic_cast<Warning const*>(it.get()))
{ {

View File

@ -491,16 +491,15 @@ bool CommandLineInterface::processInput()
// TODO: Perhaps we should not compile unless requested // TODO: Perhaps we should not compile unless requested
bool optimize = m_args.count("optimize") > 0; bool optimize = m_args.count("optimize") > 0;
unsigned runs = m_args["optimize-runs"].as<unsigned>(); unsigned runs = m_args["optimize-runs"].as<unsigned>();
if (!m_compiler->compile(optimize, runs)) bool successful = m_compiler->compile(optimize, runs);
{
for (auto const& error: m_compiler->errors()) for (auto const& error: m_compiler->errors())
SourceReferenceFormatter::printExceptionInformation( SourceReferenceFormatter::printExceptionInformation(
cerr, cerr,
*error, *error,
(dynamic_pointer_cast<Warning const>(error)) ? "Warning" : "Error", *m_compiler (dynamic_pointer_cast<Warning const>(error)) ? "Warning" : "Error", *m_compiler
); );
if (!successful)
return false; return false;
}
m_compiler->link(m_libraries); m_compiler->link(m_libraries);
} }
catch (ParserError const& _exception) catch (ParserError const& _exception)

View File

@ -45,7 +45,7 @@ namespace
{ {
pair<ASTPointer<SourceUnit>, shared_ptr<Exception const>> pair<ASTPointer<SourceUnit>, shared_ptr<Exception const>>
parseAnalyseAndReturnError(string const& _source, bool _warning = false) parseAnalyseAndReturnError(string const& _source, bool _reportWarnings = false)
{ {
Parser parser; Parser parser;
ASTPointer<SourceUnit> sourceUnit; ASTPointer<SourceUnit> sourceUnit;
@ -76,12 +76,12 @@ parseAnalyseAndReturnError(string const& _source, bool _warning = false)
{ {
for (auto const& firstError: typeChecker.errors()) for (auto const& firstError: typeChecker.errors())
{ {
if (!dynamic_pointer_cast<Warning const>(firstError)) if (_reportWarnings || !dynamic_pointer_cast<Warning const>(firstError))
{ {
err = firstError; err = firstError;
break; break;
} }
else if (_warning) else if (_reportWarnings)
{ {
err = firstError; err = firstError;
break; break;