Verified Commit 1907249f authored by Sébastien Villemot's avatar Sébastien Villemot
Browse files

Ask GCC to warn about C-style casts (-Wold-style-cast)

Adapt the code accordingly.
parent c628f212
Pipeline #1157 passed with stage
in 1 minute and 27 seconds
......@@ -44,7 +44,7 @@ esac
# Use C++ for testing headers
AC_LANG([C++])
AM_CXXFLAGS="-Wall -Wno-parentheses"
AM_CXXFLAGS="-Wall -Wno-parentheses -Wold-style-cast"
AC_SUBST([AM_CXXFLAGS])
# If default 'ar' is not available, try to find one with a host prefix (see ticket #145)
......
......@@ -1266,13 +1266,13 @@ public:
memcpy(&function_type, code, sizeof(function_type)); code += sizeof(function_type);
int size;
memcpy(&size, code, sizeof(size)); code += sizeof(size);
char *name = (char *) mxMalloc((size+1)*sizeof(char));
char *name = static_cast<char *>(mxMalloc((size+1)*sizeof(char)));
memcpy(name, code, size); code += size;
name[size] = 0;
func_name = name;
mxFree(name);
memcpy(&size, code, sizeof(size)); code += sizeof(size);
name = (char *) mxMalloc((size+1)*sizeof(char));
name = static_cast<char *>(mxMalloc((size+1)*sizeof(char)));
memcpy(name, code, size); code += size;
name[size] = 0;
arg_func_name = name;
......@@ -1699,7 +1699,7 @@ public:
}
Code_Size = CompiledCode.tellg();
CompiledCode.seekg(std::ios::beg);
code = (uint8_t *) mxMalloc(Code_Size);
code = static_cast<uint8_t *>(mxMalloc(Code_Size));
CompiledCode.seekg(0);
CompiledCode.read(reinterpret_cast<char *>(code), Code_Size);
CompiledCode.close();
......
......@@ -297,7 +297,7 @@ DynamicModel::computeTemporaryTermsOrdered()
getBlockEquationRenormalizedExpr(block, i)->computeTemporaryTerms(reference_count, temporary_terms, first_occurence, block, v_temporary_terms, i);
else
{
eq_node = (BinaryOpNode *) getBlockEquationExpr(block, i);
eq_node = static_cast<BinaryOpNode *>(getBlockEquationExpr(block, i));
eq_node->computeTemporaryTerms(reference_count, temporary_terms, first_occurence, block, v_temporary_terms, i);
}
}
......@@ -328,7 +328,7 @@ DynamicModel::computeTemporaryTermsOrdered()
getBlockEquationRenormalizedExpr(block, i)->computeTemporaryTerms(reference_count, temporary_terms, first_occurence, block, v_temporary_terms, i);
else
{
eq_node = (BinaryOpNode *) getBlockEquationExpr(block, i);
eq_node = static_cast<BinaryOpNode *>(getBlockEquationExpr(block, i));
eq_node->computeTemporaryTerms(reference_count, temporary_terms, first_occurence, block, v_temporary_terms, i);
}
}
......@@ -355,7 +355,7 @@ DynamicModel::computeTemporaryTermsOrdered()
getBlockEquationRenormalizedExpr(block, i)->collectTemporary_terms(temporary_terms, temporary_terms_in_use, block);
else
{
eq_node = (BinaryOpNode *) getBlockEquationExpr(block, i);
eq_node = static_cast<BinaryOpNode *>(getBlockEquationExpr(block, i));
eq_node->collectTemporary_terms(temporary_terms, temporary_terms_in_use, block);
}
}
......@@ -579,7 +579,7 @@ DynamicModel::writeModelEquationsOrdered_M(const string &basename) const
if (simulation_type == SOLVE_TWO_BOUNDARIES_COMPLETE || simulation_type == SOLVE_TWO_BOUNDARIES_SIMPLE)
{
temporary_terms_t tt2;
for (int i = 0; i < (int) block_size; i++)
for (int i = 0; i < static_cast<int>(block_size); i++)
{
if (v_temporary_terms[block][i].size() && global_temporary_terms)
{
......@@ -645,7 +645,7 @@ DynamicModel::writeModelEquationsOrdered_M(const string &basename) const
int equation_ID = getBlockEquationID(block, i);
EquationType equ_type = getBlockEquationType(block, i);
string sModel = symbol_table.getName(symbol_table.getID(SymbolType::endogenous, variable_ID));
eq_node = (BinaryOpNode *) getBlockEquationExpr(block, i);
eq_node = static_cast<BinaryOpNode *>(getBlockEquationExpr(block, i));
lhs = eq_node->arg1;
rhs = eq_node->arg2;
tmp_output.str("");
......@@ -673,7 +673,7 @@ DynamicModel::writeModelEquationsOrdered_M(const string &basename) const
rhs->writeOutput(output, local_output_type, local_temporary_terms, {});
output << endl << " ";
tmp_output.str("");
eq_node = (BinaryOpNode *) getBlockEquationRenormalizedExpr(block, i);
eq_node = static_cast<BinaryOpNode *>(getBlockEquationRenormalizedExpr(block, i));
lhs = eq_node->arg1;
rhs = eq_node->arg2;
lhs->writeOutput(output, local_output_type, local_temporary_terms, {});
......@@ -1360,7 +1360,7 @@ DynamicModel::writeModelEquationsCode_Block(const string &basename, const map_id
compileTemporaryTerms(code_file, instruction_number, temporary_terms, map_idx, true, false);
// The equations
for (i = 0; i < (int) block_size; i++)
for (i = 0; i < static_cast<int>(block_size); i++)
{
//The Temporary terms
temporary_terms_t tt2;
......@@ -1371,10 +1371,10 @@ DynamicModel::writeModelEquationsCode_Block(const string &basename, const map_id
if (dynamic_cast<AbstractExternalFunctionNode *>(it) != nullptr)
it->compileExternalFunctionOutput(code_file, instruction_number, false, tt2, map_idx, true, false, tef_terms);
FNUMEXPR_ fnumexpr(TemporaryTerm, (int)(map_idx.find(it->idx)->second));
FNUMEXPR_ fnumexpr(TemporaryTerm, static_cast<int>(map_idx.find(it->idx)->second));
fnumexpr.write(code_file, instruction_number);
it->compile(code_file, instruction_number, false, tt2, map_idx, true, false, tef_terms);
FSTPT_ fstpt((int)(map_idx.find(it->idx)->second));
FSTPT_ fstpt(static_cast<int>(map_idx.find(it->idx)->second));
fstpt.write(code_file, instruction_number);
// Insert current node into tt2
tt2.insert(it);
......@@ -1411,7 +1411,7 @@ DynamicModel::writeModelEquationsCode_Block(const string &basename, const map_id
}
if (equ_type == E_EVALUATE)
{
eq_node = (BinaryOpNode *) getBlockEquationExpr(block, i);
eq_node = static_cast<BinaryOpNode *>(getBlockEquationExpr(block, i));
lhs = eq_node->arg1;
rhs = eq_node->arg2;
rhs->compile(code_file, instruction_number, false, temporary_terms, map_idx, true, false);
......@@ -1419,7 +1419,7 @@ DynamicModel::writeModelEquationsCode_Block(const string &basename, const map_id
}
else if (equ_type == E_EVALUATE_S)
{
eq_node = (BinaryOpNode *) getBlockEquationRenormalizedExpr(block, i);
eq_node = static_cast<BinaryOpNode *>(getBlockEquationRenormalizedExpr(block, i));
lhs = eq_node->arg1;
rhs = eq_node->arg2;
rhs->compile(code_file, instruction_number, false, temporary_terms, map_idx, true, false);
......@@ -1430,7 +1430,7 @@ DynamicModel::writeModelEquationsCode_Block(const string &basename, const map_id
case SOLVE_FORWARD_COMPLETE:
case SOLVE_TWO_BOUNDARIES_COMPLETE:
case SOLVE_TWO_BOUNDARIES_SIMPLE:
if (i < (int) block_recursive)
if (i < static_cast<int>(block_recursive))
goto evaluation;
variable_ID = getBlockVariableID(block, i);
equation_ID = getBlockEquationID(block, i);
......@@ -1441,7 +1441,7 @@ DynamicModel::writeModelEquationsCode_Block(const string &basename, const map_id
end:
FNUMEXPR_ fnumexpr(ModelEquation, getBlockEquationID(block, i));
fnumexpr.write(code_file, instruction_number);
eq_node = (BinaryOpNode *) getBlockEquationExpr(block, i);
eq_node = static_cast<BinaryOpNode *>(getBlockEquationExpr(block, i));
lhs = eq_node->arg1;
rhs = eq_node->arg2;
lhs->compile(code_file, instruction_number, false, temporary_terms, map_idx, true, false);
......@@ -1498,12 +1498,12 @@ DynamicModel::writeModelEquationsCode_Block(const string &basename, const map_id
continue;
if (!Uf[eqr].Ufl)
{
Uf[eqr].Ufl = (Uff_l *) malloc(sizeof(Uff_l));
Uf[eqr].Ufl = static_cast<Uff_l *>(malloc(sizeof(Uff_l)));
Uf[eqr].Ufl_First = Uf[eqr].Ufl;
}
else
{
Uf[eqr].Ufl->pNext = (Uff_l *) malloc(sizeof(Uff_l));
Uf[eqr].Ufl->pNext = static_cast<Uff_l *>(malloc(sizeof(Uff_l)));
Uf[eqr].Ufl = Uf[eqr].Ufl->pNext;
}
Uf[eqr].Ufl->pNext = nullptr;
......@@ -1518,9 +1518,9 @@ DynamicModel::writeModelEquationsCode_Block(const string &basename, const map_id
count_u++;
}
}
for (i = 0; i < (int) block_size; i++)
for (i = 0; i < static_cast<int>(block_size); i++)
{
if (i >= (int) block_recursive)
if (i >= static_cast<int>(block_recursive))
{
FLDR_ fldr(i-block_recursive);
fldr.write(code_file, instruction_number);
......@@ -1938,12 +1938,12 @@ DynamicModel::Write_Inf_To_Bin_File_Block(const string &basename, const int &num
if (is_two_boundaries)
u_count_int += block_mfs;
for (j = block_recursive; j < (int) block_size; j++)
for (j = block_recursive; j < static_cast<int>(block_size); j++)
{
unsigned int varr = getBlockVariableID(num, j);
SaveCode.write(reinterpret_cast<char *>(&varr), sizeof(varr));
}
for (j = block_recursive; j < (int) block_size; j++)
for (j = block_recursive; j < static_cast<int>(block_size); j++)
{
unsigned int eqr = getBlockEquationID(num, j);
SaveCode.write(reinterpret_cast<char *>(&eqr), sizeof(eqr));
......@@ -4624,7 +4624,7 @@ DynamicModel::addPacModelConsistentExpectationEquation(const string & name, int
{
int symb_id = symbol_table.addDiffAuxiliaryVar(diff_node_to_search->idx, diff_node_to_search);
target_base_diff_node = AddVariable(symb_id);
addEquation(dynamic_cast<BinaryOpNode *>(AddEqual((expr_t) target_base_diff_node,
addEquation(dynamic_cast<BinaryOpNode *>(AddEqual(const_cast<VariableNode *>(target_base_diff_node),
AddMinus(AddVariable(pac_target_symb_id),
AddVariable(pac_target_symb_id, -1)))), -1);
neqs++;
......@@ -4666,7 +4666,7 @@ DynamicModel::addPacModelConsistentExpectationEquation(const string & name, int
fs = AddPlus(fs, AddTimes(ssum, target_aux_var_to_add[k]));
}
addEquation(AddEqual(AddVariable(mce_z1_symb_id),
AddMinus(AddTimes(A, AddMinus((expr_t) target_base_diff_node, fs)), fp)), -1);
AddMinus(AddTimes(A, AddMinus(const_cast<VariableNode *>(target_base_diff_node), fs)), fp)), -1);
neqs++;
pac_expectation_substitution[{name, eqtag}] = AddVariable(mce_z1_symb_id);
}
......@@ -5383,7 +5383,7 @@ DynamicModel::computeRamseyPolicyFOCs(const StaticModel &static_model)
// Add aux LM to constraints in equations
// equation[i]->lhs = rhs becomes equation[i]->MULT_(i+1)*(lhs-rhs) = 0
int i;
for (i = 0; i < (int) equations.size(); i++)
for (i = 0; i < static_cast<int>(equations.size()); i++)
{
auto *substeq = dynamic_cast<BinaryOpNode *>(equations[i]->addMultipliersToConstraints(i));
assert(substeq != nullptr);
......@@ -5419,7 +5419,7 @@ DynamicModel::computeRamseyPolicyFOCs(const StaticModel &static_model)
// Create (modified) Lagrangian (so that we can take the derivative once at time t)
expr_t lagrangian = Zero;
for (i = 0; i < (int) equations.size(); i++)
for (i = 0; i < static_cast<int>(equations.size()); i++)
for (int lag = -max_eq_lag; lag <= max_eq_lead; lag++)
{
expr_t dfpower = nullptr;
......@@ -5611,7 +5611,7 @@ DynamicModel::getTypeByDerivID(int deriv_id) const noexcept(false)
int
DynamicModel::getLagByDerivID(int deriv_id) const noexcept(false)
{
if (deriv_id < 0 || deriv_id >= (int) inv_deriv_id_table.size())
if (deriv_id < 0 || deriv_id >= static_cast<int>(inv_deriv_id_table.size()))
throw UnknownDerivIDException();
return inv_deriv_id_table[deriv_id].second;
......@@ -5620,7 +5620,7 @@ DynamicModel::getLagByDerivID(int deriv_id) const noexcept(false)
int
DynamicModel::getSymbIDByDerivID(int deriv_id) const noexcept(false)
{
if (deriv_id < 0 || deriv_id >= (int) inv_deriv_id_table.size())
if (deriv_id < 0 || deriv_id >= static_cast<int>(inv_deriv_id_table.size()))
throw UnknownDerivIDException();
return inv_deriv_id_table[deriv_id].first;
......@@ -5715,7 +5715,7 @@ DynamicModel::testTrendDerivativesEqualToZero(const eval_context_t &eval_context
it != deriv_id_table.end(); it++)
if (symbol_table.getType(it->first.first) == SymbolType::trend
|| symbol_table.getType(it->first.first) == SymbolType::logTrend)
for (int eq = 0; eq < (int) equations.size(); eq++)
for (int eq = 0; eq < static_cast<int>(equations.size()); eq++)
{
expr_t homogeneq = AddMinus(equations[eq]->arg1,
equations[eq]->arg2);
......@@ -6525,7 +6525,7 @@ DynamicModel::isChecksumMatching(const string &basename, bool block) const
ExprNodeOutputType buffer_type = block ? ExprNodeOutputType::matlabDynamicModelSparse : ExprNodeOutputType::CDynamicModel;
for (int eq = 0; eq < (int) equations.size(); eq++)
for (int eq = 0; eq < static_cast<int>(equations.size()); eq++)
{
BinaryOpNode *eq_node = equations[eq];
expr_t lhs = eq_node->arg1;
......@@ -6624,7 +6624,7 @@ DynamicModel::writeJsonAST(ostream &output) const
{
vector<pair<string, string>> eqtags;
output << R"("abstract_syntax_tree":[)" << endl;
for (int eq = 0; eq < (int) equations.size(); eq++)
for (int eq = 0; eq < static_cast<int>(equations.size()); eq++)
{
if (eq != 0)
output << ", ";
......
......@@ -607,13 +607,13 @@ public:
int
getBlockInitialEquationID(int block_number, int equation_number) const override
{
return ((int) inv_equation_reordered[equation_number] - (int) get<1>(block_type_firstequation_size_mfs[block_number]));
return (static_cast<int>(inv_equation_reordered[equation_number]) - static_cast<int>(get<1>(block_type_firstequation_size_mfs[block_number])));
};
//! Return the position of variable_number in the block number belonging to the block block_number
int
getBlockInitialVariableID(int block_number, int variable_number) const override
{
return ((int) inv_variable_reordered[variable_number] - (int) get<1>(block_type_firstequation_size_mfs[block_number]));
return (static_cast<int>(inv_variable_reordered[variable_number]) - static_cast<int>(get<1>(block_type_firstequation_size_mfs[block_number])));
};
//! Return the block number containing the endogenous variable variable_number
int
......
......@@ -4899,18 +4899,18 @@ BinaryOpNode::normalizeEquation(int var_endo, vector<tuple<int, expr_t, expr_t>>
{
if (op_code == BinaryOpcode::equal) /* The end of the normalization process :
All the operations needed to normalize the equation are applied. */
for (int i = 0; i < (int) List_of_Op_RHS1.size(); i++)
for (int i = 0; i < static_cast<int>(List_of_Op_RHS1.size()); i++)
{
tuple<int, expr_t, expr_t> it = List_of_Op_RHS1.back();
List_of_Op_RHS1.pop_back();
if (get<1>(it) && !get<2>(it)) /*Binary operator*/
expr_t_2 = Compute_RHS(expr_t_2, (BinaryOpNode *) get<1>(it), get<0>(it), 1);
expr_t_2 = Compute_RHS(expr_t_2, static_cast<BinaryOpNode *>(get<1>(it)), get<0>(it), 1);
else if (get<2>(it) && !get<1>(it)) /*Binary operator*/
expr_t_2 = Compute_RHS(get<2>(it), expr_t_2, get<0>(it), 1);
else if (get<2>(it) && get<1>(it)) /*Binary operator*/
expr_t_2 = Compute_RHS(get<1>(it), get<2>(it), get<0>(it), 1);
else /*Unary operator*/
expr_t_2 = Compute_RHS((UnaryOpNode *) expr_t_2, (UnaryOpNode *) get<1>(it), get<0>(it), 0);
expr_t_2 = Compute_RHS(static_cast<UnaryOpNode *>(expr_t_2), static_cast<UnaryOpNode *>(get<1>(it)), get<0>(it), 0);
}
else
List_of_Op_RHS = List_of_Op_RHS1;
......@@ -4918,18 +4918,18 @@ BinaryOpNode::normalizeEquation(int var_endo, vector<tuple<int, expr_t, expr_t>>
else if (is_endogenous_present_2)
{
if (op_code == BinaryOpcode::equal)
for (int i = 0; i < (int) List_of_Op_RHS2.size(); i++)
for (int i = 0; i < static_cast<int>(List_of_Op_RHS2.size()); i++)
{
tuple<int, expr_t, expr_t> it = List_of_Op_RHS2.back();
List_of_Op_RHS2.pop_back();
if (get<1>(it) && !get<2>(it)) /*Binary operator*/
expr_t_1 = Compute_RHS((BinaryOpNode *) expr_t_1, (BinaryOpNode *) get<1>(it), get<0>(it), 1);
expr_t_1 = Compute_RHS(static_cast<BinaryOpNode *>(expr_t_1), static_cast<BinaryOpNode *>(get<1>(it)), get<0>(it), 1);
else if (get<2>(it) && !get<1>(it)) /*Binary operator*/
expr_t_1 = Compute_RHS((BinaryOpNode *) get<2>(it), (BinaryOpNode *) expr_t_1, get<0>(it), 1);
expr_t_1 = Compute_RHS(static_cast<BinaryOpNode *>(get<2>(it)), static_cast<BinaryOpNode *>(expr_t_1), get<0>(it), 1);
else if (get<2>(it) && get<1>(it)) /*Binary operator*/
expr_t_1 = Compute_RHS(get<1>(it), get<2>(it), get<0>(it), 1);
else
expr_t_1 = Compute_RHS((UnaryOpNode *) expr_t_1, (UnaryOpNode *) get<1>(it), get<0>(it), 0);
expr_t_1 = Compute_RHS(static_cast<UnaryOpNode *>(expr_t_1), static_cast<UnaryOpNode *>(get<1>(it)), get<0>(it), 0);
}
else
List_of_Op_RHS = List_of_Op_RHS2;
......@@ -6910,7 +6910,7 @@ AbstractExternalFunctionNode::prepareForDerivation()
argument->prepareForDerivation();
non_null_derivatives = arguments.at(0)->non_null_derivatives;
for (int i = 1; i < (int) arguments.size(); i++)
for (int i = 1; i < static_cast<int>(arguments.size()); i++)
set_union(non_null_derivatives.begin(),
non_null_derivatives.end(),
arguments.at(i)->non_null_derivatives.begin(),
......@@ -7521,7 +7521,7 @@ expr_t
ExternalFunctionNode::composeDerivatives(const vector<expr_t> &dargs)
{
vector<expr_t> dNodes;
for (int i = 0; i < (int) dargs.size(); i++)
for (int i = 0; i < static_cast<int>(dargs.size()); i++)
dNodes.push_back(datatree.AddTimes(dargs.at(i),
datatree.AddFirstDerivExternalFunction(symb_id, arguments, i+1)));
......@@ -7596,7 +7596,7 @@ ExternalFunctionNode::compileExternalFunctionOutput(ostream &CompileCode, unsign
if (!alreadyWrittenAsTefTerm(symb_id, tef_terms))
{
tef_terms[{ symb_id, arguments }] = (int) tef_terms.size();
tef_terms[{ symb_id, arguments }] = static_cast<int>(tef_terms.size());
int indx = getIndxInTefTerms(symb_id, tef_terms);
int second_deriv_symb_id = datatree.external_functions_table.getSecondDerivSymbID(symb_id);
assert(second_deriv_symb_id != ExternalFunctionsTable::IDSetButNoNameProvided);
......@@ -7698,7 +7698,7 @@ ExternalFunctionNode::writeExternalFunctionOutput(ostream &output, ExprNodeOutpu
if (!alreadyWrittenAsTefTerm(symb_id, tef_terms))
{
tef_terms[{ symb_id, arguments }] = (int) tef_terms.size();
tef_terms[{ symb_id, arguments }] = static_cast<int>(tef_terms.size());
int indx = getIndxInTefTerms(symb_id, tef_terms);
int second_deriv_symb_id = datatree.external_functions_table.getSecondDerivSymbID(symb_id);
assert(second_deriv_symb_id != ExternalFunctionsTable::IDSetButNoNameProvided);
......@@ -7775,7 +7775,7 @@ ExternalFunctionNode::writeJsonExternalFunctionOutput(vector<string> &efout,
if (!alreadyWrittenAsTefTerm(symb_id, tef_terms))
{
tef_terms[{ symb_id, arguments }] = (int) tef_terms.size();
tef_terms[{ symb_id, arguments }] = static_cast<int>(tef_terms.size());
int indx = getIndxInTefTerms(symb_id, tef_terms);
int second_deriv_symb_id = datatree.external_functions_table.getSecondDerivSymbID(symb_id);
assert(second_deriv_symb_id != ExternalFunctionsTable::IDSetButNoNameProvided);
......@@ -7866,7 +7866,7 @@ expr_t
FirstDerivExternalFunctionNode::composeDerivatives(const vector<expr_t> &dargs)
{
vector<expr_t> dNodes;
for (int i = 0; i < (int) dargs.size(); i++)
for (int i = 0; i < static_cast<int>(dargs.size()); i++)
dNodes.push_back(datatree.AddTimes(dargs.at(i),
datatree.AddSecondDerivExternalFunction(symb_id, arguments, inputIndex, i+1)));
expr_t theDeriv = datatree.Zero;
......@@ -8054,7 +8054,7 @@ FirstDerivExternalFunctionNode::writeExternalFunctionOutput(ostream &output, Exp
}
else
{
tef_terms[{ first_deriv_symb_id, arguments }] = (int) tef_terms.size();
tef_terms[{ first_deriv_symb_id, arguments }] = static_cast<int>(tef_terms.size());
int indx = getIndxInTefTerms(first_deriv_symb_id, tef_terms);
stringstream ending;
ending << "_tefd_def_" << indx;
......@@ -8080,7 +8080,7 @@ FirstDerivExternalFunctionNode::writeExternalFunctionOutput(ostream &output, Exp
<< datatree.symbol_table.getName(symb_id) << "'," << inputIndex << ",{";
else
{
tef_terms[{ first_deriv_symb_id, arguments }] = (int) tef_terms.size();
tef_terms[{ first_deriv_symb_id, arguments }] = static_cast<int>(tef_terms.size());
output << "TEFD_def_" << getIndxInTefTerms(first_deriv_symb_id, tef_terms)
<< " = " << datatree.symbol_table.getName(first_deriv_symb_id) << "(";
}
......@@ -8123,7 +8123,7 @@ FirstDerivExternalFunctionNode::writeJsonExternalFunctionOutput(vector<string> &
<< R"(, "value": ")" << datatree.symbol_table.getName(symb_id) << "(";
else
{
tef_terms[{ first_deriv_symb_id, arguments }] = (int) tef_terms.size();
tef_terms[{ first_deriv_symb_id, arguments }] = static_cast<int>(tef_terms.size());
ef << R"({"first_deriv_external_function": {)"
<< R"("external_function_term": "TEFD_def_)" << getIndxInTefTerms(first_deriv_symb_id, tef_terms) << R"(")"
<< R"(, "analytic_derivative": true)"
......@@ -8165,7 +8165,7 @@ FirstDerivExternalFunctionNode::compileExternalFunctionOutput(ostream &CompileCo
}
else
{
tef_terms[{ first_deriv_symb_id, arguments }] = (int) tef_terms.size();
tef_terms[{ first_deriv_symb_id, arguments }] = static_cast<int>(tef_terms.size());
int indx = getIndxInTefTerms(symb_id, tef_terms);
int second_deriv_symb_id = datatree.external_functions_table.getSecondDerivSymbID(symb_id);
assert(second_deriv_symb_id != ExternalFunctionsTable::IDSetButNoNameProvided);
......@@ -8419,7 +8419,7 @@ SecondDerivExternalFunctionNode::writeExternalFunctionOutput(ostream &output, Ex
}
else
{
tef_terms[{ second_deriv_symb_id, arguments }] = (int) tef_terms.size();
tef_terms[{ second_deriv_symb_id, arguments }] = static_cast<int>(tef_terms.size());
int indx = getIndxInTefTerms(second_deriv_symb_id, tef_terms);
stringstream ending;
ending << "_tefdd_def_" << indx;
......@@ -8447,7 +8447,7 @@ SecondDerivExternalFunctionNode::writeExternalFunctionOutput(ostream &output, Ex
<< inputIndex1 << "," << inputIndex2 << ",{";
else
{
tef_terms[{ second_deriv_symb_id, arguments }] = (int) tef_terms.size();
tef_terms[{ second_deriv_symb_id, arguments }] = static_cast<int>(tef_terms.size());
output << "TEFDD_def_" << getIndxInTefTerms(second_deriv_symb_id, tef_terms)
<< " = " << datatree.symbol_table.getName(second_deriv_symb_id) << "(";
}
......@@ -8491,7 +8491,7 @@ SecondDerivExternalFunctionNode::writeJsonExternalFunctionOutput(vector<string>
<< R"(, "value": ")" << datatree.symbol_table.getName(symb_id) << "(";
else
{
tef_terms[{ second_deriv_symb_id, arguments }] = (int) tef_terms.size();
tef_terms[{ second_deriv_symb_id, arguments }] = static_cast<int>(tef_terms.size());
ef << R"({"second_deriv_external_function": {)"
<< R"("external_function_term": "TEFDD_def_)" << getIndxInTefTerms(second_deriv_symb_id, tef_terms) << R"(")"
<< R"(, "analytic_derivative": true)"
......
......@@ -134,7 +134,7 @@ isLatexOutput(ExprNodeOutputType output_type)
/* Equal to 1 for Matlab langage or Julia, or to 0 for C language. Not defined for LaTeX.
In Matlab and Julia, array indexes begin at 1, while they begin at 0 in C */
#define ARRAY_SUBSCRIPT_OFFSET(output_type) ((int) (isMatlabOutput(output_type) || isJuliaOutput(output_type)))
#define ARRAY_SUBSCRIPT_OFFSET(output_type) (static_cast<int>(isMatlabOutput(output_type) || isJuliaOutput(output_type)))
// Left and right array subscript delimiters: '(' and ')' for Matlab, '[' and ']' for C
#define LEFT_ARRAY_SUBSCRIPT(output_type) (isMatlabOutput(output_type) ? '(' : '[')
......
......@@ -72,6 +72,8 @@ DynareFlex.cc FlexLexer.h: DynareFlex.ll
$(LEX) -o DynareFlex.cc DynareFlex.ll
cp $(LEXINC)/FlexLexer.h . || test -f ./FlexLexer.h
dynare_m-DynareFlex.$(OBJEXT): CXXFLAGS += -Wno-old-style-cast
DynareBison.cc DynareBison.hh location.hh stack.hh position.hh: DynareBison.yy
$(YACC) -W -o DynareBison.cc DynareBison.yy
......
......@@ -371,7 +371,7 @@ ModelTree::computeNormalizedEquations(multimap<int, int> &endo2eqs) const
if (endo.find({ symbol_table.getTypeSpecificID(symb_id), 0 }) != endo.end())
continue;
endo2eqs.emplace(symbol_table.getTypeSpecificID(symb_id), (int) i);
endo2eqs.emplace(symbol_table.getTypeSpecificID(symb_id), static_cast<int>(i));
cout << "Endogenous " << symbol_table.getName(symb_id) << " normalized in equation " << (i+1) << endl;
}
}
......@@ -517,7 +517,7 @@ ModelTree::computeNaturalNormalization()
bool bool_result = true;
set<pair<int, int> > result;
endo2eq.resize(equations.size());
for (int eq = 0; eq < (int) equations.size(); eq++)
for (int eq = 0; eq < static_cast<int>(equations.size()); eq++)
if (!is_equation_linear[eq])
{
BinaryOpNode *eq_node = equations[eq];
......@@ -621,7 +621,7 @@ ModelTree::computePrologueAndEpilogue(const jacob_map_t &static_jacobian_arg, ve
{
int tmp_epilogue = epilogue;
something_has_been_done = false;
for (int i = prologue; i < n - (int) epilogue; i++)
for (int i = prologue; i < n - static_cast<int>(epilogue); i++)
{
int nze = 0;
for (int j = prologue; j < n - tmp_epilogue; j++)
......@@ -712,12 +712,12 @@ ModelTree::getVariableLeadLagByBlock(const dynamic_jacob_map_t &dynamic_jacobian
vector<int> variable_blck(nb_endo), equation_blck(nb_endo);
for (int i = 0; i < nb_endo; i++)
{
if (i < (int) prologue)
if (i < static_cast<int>(prologue))
{
variable_blck[variable_reordered[i]] = i;
equation_blck[equation_reordered[i]] = i;
}
else if (i < (int) (components_set.size() + prologue))
else if (i < static_cast<int>(components_set.size() + prologue))
{
variable_blck[variable_reordered[i]] = components_set[i-prologue] + prologue;
equation_blck[equation_reordered[i]] = components_set[i-prologue] + prologue;
......@@ -782,8 +782,8 @@ ModelTree::computeBlockDecompositionAndFeedbackVariablesForEachBlock(const jacob
else
tmp_normalized_contemporaneous_jacobian = static_jacobian;
for (const auto &it : tmp_normalized_contemporaneous_jacobian)
if (reverse_equation_reordered[it.first.first] >= (int) prologue && reverse_equation_reordered[it.first.first] < (int) (nb_var - epilogue)
&& reverse_variable_reordered[it.first.second] >= (int) prologue && reverse_variable_reordered[it.first.second] < (int) (nb_var - epilogue)
if (reverse_equation_reordered[it.first.first] >= static_cast<int>(prologue) && reverse_equation_reordered[it.first.first] < static_cast<int>(nb_var - epilogue)
&& reverse_variable_reordered[it.first.second] >= static_cast<int>(prologue) && reverse_variable_reordered[it.first.second] < static_cast<int>(nb_var - epilogue)
&& it.first.first != endo2eq[it.first.second])
add_edge(vertex(reverse_equation_reordered[endo2eq[it.first.second]]-prologue, G2),
vertex(reverse_equation_reordered[it.first.first]-prologue, G2),
......@@ -863,7 +863,7 @@ ModelTree::computeBlockDecompositionAndFeedbackVariablesForEachBlock(const jacob
n_backward = vector<unsigned int>(prologue+num+epilogue, 0);
n_mixed = vector<unsigned int>(prologue+num+epilogue, 0);
for (int i = 0; i < (int) prologue; i++)
for (int i = 0; i < static_cast<int>(prologue); i++)
{
if (variable_lag_lead[tmp_variable_reordered[i]].first != 0 && variable_lag_lead[tmp_variable_reordered[i]].second != 0)
n_mixed[i]++;
......@@ -961,7 +961,7 @@ ModelTree::computeBlockDecompositionAndFeedbackVariablesForEachBlock(const jacob
}
}
for (int i = 0; i < (int) epilogue; i++)
for (int i = 0; i < static_cast<int>(epilogue); i++)
{
if (variable_lag_lead[tmp_variable_reordered[prologue+n+i]].first != 0 && variable_lag_lead[tmp_variable_reordered[prologue+n+i]].second != 0)
n_mixed[prologue+num+i]++;
......@@ -1025,21 +1025,21 @@ ModelTree::reduceBlocksAndTypeDetermination(const dynamic_jacob_map_t &dynamic_j
unsigned int l_n_forward = 0;
unsigned int l_n_backward = 0;
unsigned int l_n_mixed = 0;
for (i = 0; i < (int) (prologue+blocks.size()+epilogue); i++)
for (i = 0; i < static_cast<int>(prologue+blocks.size()+epilogue); i++)
{
int first_count_equ = count_equ;
if (i < (int) prologue)
if (i < static_cast<int>(prologue))
{
Blck_Size = 1;
MFS_Size = 1;
}
else if (i < (int) (prologue+blocks.size()))
else if (i < static_cast<int>(prologue+blocks.size()))
{
Blck_Size = blocks[blck_count_simult].first;
MFS_Size = blocks[blck_count_simult].second;
blck_count_simult++;
}
else if (i < (int) (prologue+blocks.size()+epilogue))
else if (i < static_cast<int>(prologue+blocks.size()+epilogue))
{
Blck_Size = 1;
MFS_Size = 1;
......@@ -1348,7 +1348,7 @@ ModelTree::computeTemporaryTerms(bool is_matlab, bool no_tmp_terms)
reference_count,
is_matlab);
for (int order = 1; order < (int) derivatives.size(); order++)
for (int order = 1; order < static_cast<int>(derivatives.size()); order++)
for (const auto &it : derivatives[order])
it.second->computeTemporaryTerms({ 0, order },
temp_terms_map,
......@@ -1364,14 +1364,14 @@ ModelTree::computeTemporaryTerms(bool is_matlab, bool no_tmp_terms)
// Fill the new structure
temporary_terms_derivatives.clear();
temporary_terms_derivatives.resize(derivatives.size());
for (int order = 0; order < (int) derivatives.size(); order++)
for (int order = 0; order < static_cast<int>(derivatives.size()); order++)
temporary_terms_derivatives[order] = move(temp_terms_map[{ 0, order }]);
// Compute indices in MATLAB/Julia vector
int idx = 0;
for (auto &it : temporary_terms_mlv)
temporary_terms_idxs[it.first] = idx++;
for (int order = 0; order < (int) derivatives.size(); order++)
for (int order = 0; order < static_cast<int>(derivatives.size()); order++)
for (const auto &it : temporary_terms_derivatives[order])
temporary_terms_idxs[it] = idx++;
}
......@@ -1618,17 +1618,17 @@ ModelTree::compileTemporaryTerms(ostream &code_file, unsigned int &instruction_n
it->compileExternalFunctionOutput(code_file, instruction_number, false, tt2, map_idx, dynamic, steady_dynamic, tef_terms);
}
FNUMEXPR_ fnumexpr(TemporaryTerm, (int)(map_idx.find(it->idx)->second));
FNUMEXPR_ fnumexpr(TemporaryTerm, static_cast<int>(map_idx.find(it->idx)->second));
fnumexpr.write(code_file, instruction_number);
it->compile(code_file, instruction_number, false, tt2, map_idx, dynamic, steady_dynamic, tef_terms);
if (dynamic)
{
FSTPT_ fstpt((int)(map_idx.find(it->idx)->second));
FSTPT_ fstpt(static_cast<int>(map_idx.find(it->idx)->second));
fstpt.write(code_file, instruction_number);
}
else
{
FSTPST_ fstpst((int)(map_idx.find(it->idx)->second));
FSTPST_ fstpst(static_cast<int>(map_idx.find(it->idx)->second));
fstpst.write(code_file, instruction_number);