diff --git a/vhdlpp/architec.h b/vhdlpp/architec.h index 052628f0d..5615f645b 100644 --- a/vhdlpp/architec.h +++ b/vhdlpp/architec.h @@ -1,7 +1,7 @@ #ifndef IVL_architec_H #define IVL_architec_H /* - * Copyright (c) 2011-2014 Stephen Williams (steve@icarus.com) + * Copyright (c) 2011-2021 Stephen Williams (steve@icarus.com) * * This source code is free software; you can redistribute it * and/or modify it in source code form under the terms of the GNU @@ -249,7 +249,7 @@ class ComponentInstantiation : public Architecture::Statement { class StatementList : public Architecture::Statement { public: - StatementList(std::list*statement_list); + explicit StatementList(std::list*statement_list); virtual ~StatementList(); int elaborate(Entity*ent, Architecture*arc) { @@ -274,7 +274,7 @@ class StatementList : public Architecture::Statement { // but we can still use it during the translation process. class InitialStatement : public StatementList { public: - InitialStatement(std::list*statement_list) + explicit InitialStatement(std::list*statement_list) : StatementList(statement_list) {} int emit(ostream&out, Entity*entity, ScopeBase*scope); @@ -285,7 +285,7 @@ class InitialStatement : public StatementList { // but we can still use it during the translation process. class FinalStatement : public StatementList { public: - FinalStatement(std::list*statement_list) + explicit FinalStatement(std::list*statement_list) : StatementList(statement_list) {} int emit(ostream&out, Entity*entity, ScopeBase*scope); diff --git a/vhdlpp/architec_elaborate.cc b/vhdlpp/architec_elaborate.cc index cb472977a..561cd7c66 100644 --- a/vhdlpp/architec_elaborate.cc +++ b/vhdlpp/architec_elaborate.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011-2012 Stephen Williams (steve@icarus.com) + * Copyright (c) 2011-2021 Stephen Williams (steve@icarus.com) * * This source code is free software; you can redistribute it * and/or modify it in source code form under the terms of the GNU @@ -250,7 +250,7 @@ int CondSignalAssignment::elaborate(Entity*ent, Architecture*arc) // Visitor to extract signal names occurring in the conditional // statements to create the sensitivity list struct name_extractor_t : public ExprVisitor { - name_extractor_t(list& name_list) + explicit name_extractor_t(list& name_list) : name_list_(name_list) {} void operator() (Expression*s) { if(const ExpName*name = dynamic_cast(s)) diff --git a/vhdlpp/debug.cc b/vhdlpp/debug.cc index 717687d68..8f9e411be 100644 --- a/vhdlpp/debug.cc +++ b/vhdlpp/debug.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011 Stephen Williams (steve@icarus.com) + * Copyright (c) 2011-2021 Stephen Williams (steve@icarus.com) * Copyright (c) 2014 CERN * @author Maciej Suminski (maciej.suminski@cern.ch) * @@ -151,7 +151,7 @@ void ScopeBase::dump_scope(ostream&out) const // Dump subprograms out << " -- Imported Subprograms" << endl; for (map::const_iterator cur = use_subprograms_.begin() - ; cur != cur_subprograms_.end() ; ++ cur) { + ; cur != use_subprograms_.end() ; ++cur) { const SubHeaderList& subp_list = cur->second; for(SubHeaderList::const_iterator it = subp_list.begin(); diff --git a/vhdlpp/library.cc b/vhdlpp/library.cc index 44555f220..1203b987c 100644 --- a/vhdlpp/library.cc +++ b/vhdlpp/library.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011-2013 Stephen Williams (steve@icarus.com) + * Copyright (c) 2011-2021 Stephen Williams (steve@icarus.com) * Copyright CERN 2013 / Stephen Williams (steve@icarus.com) * Copyright CERN 2016 * @author Maciej Suminski @@ -455,7 +455,7 @@ int emit_packages(void) errors += emit_packages(cur->first, cur->second.packages); } - return 0; + return errors; } static int elaborate_library_packages(mappackages) diff --git a/vhdlpp/main.cc b/vhdlpp/main.cc index d6f3a51d4..e5640caf9 100644 --- a/vhdlpp/main.cc +++ b/vhdlpp/main.cc @@ -168,7 +168,7 @@ int main(int argc, char*argv[]) debug_log_file.open(debug_log_path); } - if ( (rc = mkdir(work_path, 0777)) < 0 ) { + if ( (mkdir(work_path, 0777)) < 0 ) { if (errno != EEXIST) { fprintf(stderr, "Icarus Verilog VHDL unable to create work directory %s, errno=%d\n", work_path, errno); return -1; @@ -176,7 +176,7 @@ int main(int argc, char*argv[]) struct stat stat_buf; rc = stat(work_path, &stat_buf); - if (!S_ISDIR(stat_buf.st_mode)) { + if (rc || !S_ISDIR(stat_buf.st_mode)) { fprintf(stderr, "Icarus Verilog VHDL work path `%s' is not a directory.\n", work_path); return -1; } diff --git a/vhdlpp/parse_types.h b/vhdlpp/parse_types.h index 711d45a0b..146fddec6 100644 --- a/vhdlpp/parse_types.h +++ b/vhdlpp/parse_types.h @@ -1,7 +1,7 @@ #ifndef IVL_parse_types_H #define IVL_parse_types_H /* - * Copyright (c) 2011-2015 Stephen Williams (steve@icarus.com) + * Copyright (c) 2011-2021 Stephen Williams (steve@icarus.com) * Copyright CERN 2013 / Stephen Williams (steve@icarus.com) * * This source code is free software; you can redistribute it @@ -78,7 +78,7 @@ struct adding_term { // (VHDL-2008 6.4.2.5) class file_open_info_t { public: - file_open_info_t(ExpString*filename__, ExpName*kind__ = NULL) + explicit file_open_info_t(ExpString*filename__, ExpName*kind__ = NULL) : kind_(kind__), filename_(filename__) { // By default files are opened in read-only mode if(!kind_) kind_ = new ExpName(perm_string::literal("read_mode")); diff --git a/vhdlpp/sequential.cc b/vhdlpp/sequential.cc index 9f83c1372..5e677070d 100644 --- a/vhdlpp/sequential.cc +++ b/vhdlpp/sequential.cc @@ -50,17 +50,17 @@ IfSequential::IfSequential(Expression*cond, std::list*tr, IfSequential::~IfSequential() { delete cond_; - while (if_.size() > 0) { + while (!if_.empty()) { SequentialStmt*cur = if_.front(); if_.pop_front(); delete cur; } - while (elsif_.size() > 0) { + while (!elsif_.empty()) { IfSequential::Elsif*cur = elsif_.front(); elsif_.pop_front(); delete cur; } - while (else_.size() > 0) { + while (!else_.empty()) { SequentialStmt*cur = else_.front(); else_.pop_front(); delete cur; @@ -101,7 +101,7 @@ IfSequential::Elsif::Elsif(Expression*cond, std::list*tr) IfSequential::Elsif::~Elsif() { delete cond_; - while (if_.size() > 0) { + while (!if_.empty()) { SequentialStmt*cur = if_.front(); if_.pop_front(); delete cur; @@ -133,7 +133,7 @@ CaseSeqStmt::CaseSeqStmt(Expression*cond, list 0) { + while(!alt_.empty()) { CaseSeqStmt::CaseStmtAlternative* cur = alt_.front(); alt_.pop_front(); delete cur; @@ -156,7 +156,7 @@ CaseSeqStmt::CaseStmtAlternative::CaseStmtAlternative(std::list*exp CaseSeqStmt::CaseStmtAlternative::~CaseStmtAlternative() { delete exp_; - while(stmts_.size() > 0) { + while(!stmts_.empty()) { SequentialStmt* cur = stmts_.front(); stmts_.pop_front(); delete cur; @@ -194,7 +194,7 @@ ProcedureCall::~ProcedureCall() if(!param_list_) return; - while(param_list_->size() > 0) { + while(!param_list_->empty()) { named_expr_t* cur = param_list_->front(); param_list_->pop_front(); delete cur; @@ -227,7 +227,7 @@ LoopStatement::LoopStatement(perm_string name, list* stmts) LoopStatement::~LoopStatement() { - while(stmts_.size() > 0) { + while(!stmts_.empty()) { SequentialStmt* cur = stmts_.front(); stmts_.pop_front(); delete cur; diff --git a/vhdlpp/sequential_elaborate.cc b/vhdlpp/sequential_elaborate.cc index 84a48f55b..6326eccb9 100644 --- a/vhdlpp/sequential_elaborate.cc +++ b/vhdlpp/sequential_elaborate.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011 Stephen Williams (steve@icarus.com) + * Copyright (c) 2011-2021 Stephen Williams (steve@icarus.com) * * This source code is free software; you can redistribute it * and/or modify it in source code form under the terms of the GNU @@ -203,8 +203,8 @@ int ProcedureCall::elaborate(Entity*ent, ScopeBase*scope) } // Elaborate arguments - size_t idx = 0; if(param_list_) { + size_t idx = 0; for(list::iterator cur = param_list_->begin() ; cur != param_list_->end() ; ++cur) { errors += def_->elaborate_argument((*cur)->expr(), idx, ent, scope); diff --git a/vhdlpp/sequential_emit.cc b/vhdlpp/sequential_emit.cc index 359366cd1..4f776e7d4 100644 --- a/vhdlpp/sequential_emit.cc +++ b/vhdlpp/sequential_emit.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011-2020 Stephen Williams (steve@icarus.com) + * Copyright (c) 2011-2021 Stephen Williams (steve@icarus.com) * Copyright CERN 2013 / Stephen Williams (steve@icarus.com) * Copyright CERN 2015 * @author Maciej Suminski (maciej.suminski@cern.ch) @@ -296,8 +296,8 @@ int CaseSeqStmt::CaseStmtAlternative::emit(ostream&out, Entity*ent, ScopeBase*sc { int errors = 0; - bool first = true; if (exp_) { + bool first = true; for (list::iterator it = exp_->begin(); it != exp_->end(); ++it) { if(first) first = false; diff --git a/vhdlpp/std_types.cc b/vhdlpp/std_types.cc index 51f6eaa2d..5f0eb953a 100644 --- a/vhdlpp/std_types.cc +++ b/vhdlpp/std_types.cc @@ -1,5 +1,5 @@ /* - * Copyright CERN 2015 + * Copyright CERN 2015-2021 * @author Maciej Suminski (maciej.suminski@cern.ch) * * This source code is free software; you can redistribute it @@ -90,7 +90,6 @@ void generate_global_types(ActiveScope*res) void delete_global_types() { - typedef_context_t typedef_ctx; for(map::iterator cur = std_types.begin(); cur != std_types.end(); ++cur) { delete cur->second->peek_definition(); diff --git a/vhdlpp/vtype.h b/vhdlpp/vtype.h index 4f34c62ac..bb3c2c910 100644 --- a/vhdlpp/vtype.h +++ b/vhdlpp/vtype.h @@ -1,7 +1,7 @@ #ifndef IVL_vtype_H #define IVL_vtype_H /* - * Copyright (c) 2011-2014 Stephen Williams (steve@icarus.com) + * Copyright (c) 2011-2021 Stephen Williams (steve@icarus.com) * Copyright CERN 2014 / Stephen Williams (steve@icarus.com), * @author Maciej Suminski (maciej.suminski@cern.ch) * @@ -161,7 +161,7 @@ class VTypePrimitive : public VType { enum type_t { BIT, INTEGER, NATURAL, REAL, STDLOGIC, TIME }; public: - VTypePrimitive(type_t tt, bool packed = false); + explicit VTypePrimitive(type_t tt, bool packed = false); ~VTypePrimitive(); VType*clone() const { return new VTypePrimitive(*this); }