From e1e1a753d0e96003f7c54d93e58b52aa5346c53d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Villemot?= <sebastien@dynare.org> Date: Fri, 7 Jul 2023 14:29:22 +0200 Subject: [PATCH] Do not use C++20 aggregate initialization with parentheses Initialization with initalizer list is nicer. And, more importantly, initialization with parentheses is not supported by Clang < 16. --- src/DataTree.cc | 2 +- src/DataTree.hh | 2 +- src/ExprNode.cc | 8 ++++---- src/ExternalFunctionsTable.hh | 6 +++--- src/ModelTree.cc | 4 ++-- src/SymbolTable.cc | 20 ++++++++++---------- src/SymbolTable.hh | 8 ++++---- 7 files changed, 25 insertions(+), 25 deletions(-) diff --git a/src/DataTree.cc b/src/DataTree.cc index d90d6853..72f872fe 100644 --- a/src/DataTree.cc +++ b/src/DataTree.cc @@ -734,7 +734,7 @@ DataTree::AddLocalVariable(int symb_id, expr_t value) noexcept(false) // Throw an exception if symbol already declared if (local_variables_table.contains(symb_id)) - throw LocalVariableException(symbol_table.getName(symb_id)); + throw LocalVariableException{symbol_table.getName(symb_id)}; local_variables_table.emplace(symb_id, value); local_variables_vector.push_back(symb_id); diff --git a/src/DataTree.hh b/src/DataTree.hh index c3f351ba..74e2916d 100644 --- a/src/DataTree.hh +++ b/src/DataTree.hh @@ -353,7 +353,7 @@ public: { auto it = local_variables_table.find(symb_id); if (it == local_variables_table.end()) - throw UnknownLocalVariableException(symb_id); + throw UnknownLocalVariableException{symb_id}; return it->second; } diff --git a/src/ExprNode.cc b/src/ExprNode.cc index 7b8c4151..b6a1fe71 100644 --- a/src/ExprNode.cc +++ b/src/ExprNode.cc @@ -5833,18 +5833,18 @@ BinaryOpNode::matchMatchedMoment(vector<int> &symb_ids, vector<int> &lags, vecto else if (op_code == BinaryOpcode::power) { if (!dynamic_cast<const VariableNode *>(arg1)) - throw MatchFailureException("First argument of power expression must be a variable"); + throw MatchFailureException{"First argument of power expression must be a variable"}; auto ncn = dynamic_cast<const NumConstNode *>(arg2); if (!ncn) - throw MatchFailureException("Second argument of power expression must be a positive integer"); + throw MatchFailureException{"Second argument of power expression must be a positive integer"}; double c = datatree.num_constants.getDouble(ncn->id); if (c <= 0 || round(c) != c) - throw MatchFailureException("Second argument of power expression must be a positive integer"); + throw MatchFailureException{"Second argument of power expression must be a positive integer"}; arg1->matchMatchedMoment(symb_ids, lags, powers); powers.back() = static_cast<int>(c); } else - throw MatchFailureException("Unsupported binary operator"); + throw MatchFailureException{"Unsupported binary operator"}; } expr_t diff --git a/src/ExternalFunctionsTable.hh b/src/ExternalFunctionsTable.hh index 39fbd67f..16009289 100644 --- a/src/ExternalFunctionsTable.hh +++ b/src/ExternalFunctionsTable.hh @@ -84,7 +84,7 @@ ExternalFunctionsTable::getNargs(int symb_id) const noexcept(false) it != externalFunctionTable.end()) return it->second.nargs; else - throw UnknownExternalFunctionSymbolIDException(symb_id); + throw UnknownExternalFunctionSymbolIDException{symb_id}; } inline int @@ -94,7 +94,7 @@ ExternalFunctionsTable::getFirstDerivSymbID(int symb_id) const noexcept(false) it != externalFunctionTable.end()) return it->second.firstDerivSymbID; else - throw UnknownExternalFunctionSymbolIDException(symb_id); + throw UnknownExternalFunctionSymbolIDException{symb_id}; } inline int @@ -104,7 +104,7 @@ ExternalFunctionsTable::getSecondDerivSymbID(int symb_id) const noexcept(false) it != externalFunctionTable.end()) return it->second.secondDerivSymbID; else - throw UnknownExternalFunctionSymbolIDException(symb_id); + throw UnknownExternalFunctionSymbolIDException{symb_id}; } #endif diff --git a/src/ModelTree.cc b/src/ModelTree.cc index 36e9ad2a..681d8a37 100644 --- a/src/ModelTree.cc +++ b/src/ModelTree.cc @@ -1419,7 +1419,7 @@ ModelTree::addTrendVariables(const vector<int> &trend_vars, expr_t growth_factor { for (int id : trend_vars) if (trend_symbols_map.contains(id)) - throw TrendException(symbol_table.getName(id)); + throw TrendException{symbol_table.getName(id)}; else trend_symbols_map[id] = growth_factor; } @@ -1429,7 +1429,7 @@ ModelTree::addNonstationaryVariables(const vector<int> &nonstationary_vars, bool { for (int id : nonstationary_vars) if (nonstationary_symbols_map.contains(id)) - throw TrendException(symbol_table.getName(id)); + throw TrendException{symbol_table.getName(id)}; else nonstationary_symbols_map[id] = { log_deflator, deflator }; } diff --git a/src/SymbolTable.cc b/src/SymbolTable.cc index 435ce5c5..463532e6 100644 --- a/src/SymbolTable.cc +++ b/src/SymbolTable.cc @@ -38,9 +38,9 @@ SymbolTable::addSymbol(const string &name, SymbolType type, const string &tex_na if (exists(name)) { if (type_table[getID(name)] == type) - throw AlreadyDeclaredException(name, true); + throw AlreadyDeclaredException{name, true}; else - throw AlreadyDeclaredException(name, false); + throw AlreadyDeclaredException{name, false}; } string final_tex_name = tex_name; @@ -154,26 +154,26 @@ SymbolTable::getID(SymbolType type, int tsid) const noexcept(false) { case SymbolType::endogenous: if (tsid < 0 || tsid >= static_cast<int>(endo_ids.size())) - throw UnknownTypeSpecificIDException(tsid, type); + throw UnknownTypeSpecificIDException{tsid, type}; else return endo_ids[tsid]; case SymbolType::exogenous: if (tsid < 0 || tsid >= static_cast<int>(exo_ids.size())) - throw UnknownTypeSpecificIDException(tsid, type); + throw UnknownTypeSpecificIDException{tsid, type}; else return exo_ids[tsid]; case SymbolType::exogenousDet: if (tsid < 0 || tsid >= static_cast<int>(exo_det_ids.size())) - throw UnknownTypeSpecificIDException(tsid, type); + throw UnknownTypeSpecificIDException{tsid, type}; else return exo_det_ids[tsid]; case SymbolType::parameter: if (tsid < 0 || tsid >= static_cast<int>(param_ids.size())) - throw UnknownTypeSpecificIDException(tsid, type); + throw UnknownTypeSpecificIDException{tsid, type}; else return param_ids[tsid]; default: - throw UnknownTypeSpecificIDException(tsid, type); + throw UnknownTypeSpecificIDException{tsid, type}; } } @@ -671,7 +671,7 @@ SymbolTable::searchAuxiliaryVars(int orig_symb_id, int orig_lead_lag) const noex if ((aux_var.type == AuxVarType::endoLag || aux_var.type == AuxVarType::exoLag) && aux_var.orig_symb_id == orig_symb_id && aux_var.orig_lead_lag == orig_lead_lag) return aux_var.symb_id; - throw SearchFailedException(orig_symb_id, orig_lead_lag); + throw SearchFailedException{orig_symb_id, orig_lead_lag}; } int @@ -690,9 +690,9 @@ SymbolTable::getOrigSymbIdForAuxVar(int aux_var_symb_id_arg) const noexcept(fals if (optional<int> r = aux_var.orig_symb_id; r) return *r; else - throw UnknownSymbolIDException(aux_var_symb_id_arg); // Some diff and unaryOp auxvars have orig_symb_id unset + throw UnknownSymbolIDException{aux_var_symb_id_arg}; // Some diff and unaryOp auxvars have orig_symb_id unset } - throw UnknownSymbolIDException(aux_var_symb_id_arg); + throw UnknownSymbolIDException{aux_var_symb_id_arg}; } pair<int, int> diff --git a/src/SymbolTable.hh b/src/SymbolTable.hh index 316882e9..da9b234c 100644 --- a/src/SymbolTable.hh +++ b/src/SymbolTable.hh @@ -419,7 +419,7 @@ inline void SymbolTable::validateSymbID(int symb_id) const noexcept(false) { if (symb_id < 0 || symb_id > static_cast<int>(symbol_table.size())) - throw UnknownSymbolIDException(symb_id); + throw UnknownSymbolIDException{symb_id}; } inline bool @@ -469,7 +469,7 @@ SymbolTable::getID(const string &name) const noexcept(false) iter != symbol_table.end()) return iter->second; else - throw UnknownSymbolNameException(name); + throw UnknownSymbolNameException{name}; } inline int @@ -484,7 +484,7 @@ SymbolTable::getTypeSpecificID(int id) const noexcept(false) it != type_specific_ids.end()) return it->second; else - throw NoTypeSpecificIDException(id); + throw NoTypeSpecificIDException{id}; } inline int @@ -547,7 +547,7 @@ SymbolTable::getAuxVarInfo(int symb_id) const for (const auto &aux_var : aux_vars) if (aux_var.symb_id == symb_id) return aux_var; - throw UnknownSymbolIDException(symb_id); + throw UnknownSymbolIDException{symb_id}; } #endif -- GitLab