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

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();
......
This diff is collapsed.
......@@ -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
......
This diff is collapsed.
......@@ -33,7 +33,7 @@ NumericalConstants::AddNonNegativeConstant(const string &iConst)
if (iter != numConstantsIndex.end())
return iter->second;
auto id = (int) mNumericalConstants.size();
auto id = static_cast<int>(mNumericalConstants.size());
mNumericalConstants.push_back(iConst);
numConstantsIndex[iConst] = id;
......@@ -52,13 +52,13 @@ NumericalConstants::AddNonNegativeConstant(const string &iConst)
string
NumericalConstants::get(int ID) const
{
assert(ID >= 0 && ID < (int) mNumericalConstants.size());
assert(ID >= 0 && ID < static_cast<int>(mNumericalConstants.size()));
return mNumericalConstants[ID];
}
double
NumericalConstants::getDouble(int ID) const
{
assert(ID >= 0 && ID < (int) double_vals.size());
assert(ID >= 0 && ID < static_cast<int>(double_vals.size()));
return (double_vals[ID]);
}
......@@ -3022,7 +3022,7 @@ ParsingDriver::add_model_var_or_external_function(const string &function_name, b
model_error("Symbol " + function_name +
" is being treated as if it were a function (i.e., takes an argument that is not an integer).", "");
nid = add_model_variable(mod_file->symbol_table.getID(function_name), (int) rv.second);
nid = add_model_variable(mod_file->symbol_table.getID(function_name), static_cast<int>(rv.second));
stack_external_function_args.pop();
return nid;
}
......@@ -3037,7 +3037,7 @@ ParsingDriver::add_model_var_or_external_function(const string &function_name, b
if (mod_file->external_functions_table.getNargs(symb_id) == ExternalFunctionsTable::IDNotSet)
error("Before using " + function_name
+"() in the model block, you must first declare it via the external_function() statement");
else if ((int) (stack_external_function_args.top().size()) != mod_file->external_functions_table.getNargs(symb_id))
else if (static_cast<int>(stack_external_function_args.top().size()) != mod_file->external_functions_table.getNargs(symb_id))
error("The number of arguments passed to " + function_name
+"() does not match those of a previous call or declaration of this function.");
}
......@@ -3058,7 +3058,7 @@ ParsingDriver::add_model_var_or_external_function(const string &function_name, b
{
// assume it's a lead/lagged variable
declare_exogenous(function_name);
return add_model_variable(mod_file->symbol_table.getID(function_name), (int) rv.second);
return add_model_variable(mod_file->symbol_table.getID(function_name), static_cast<int>(rv.second));
}
else
error("To use an external function (" + function_name +
......@@ -3301,7 +3301,7 @@ ParsingDriver::smm_estimation()
void
ParsingDriver::prior_posterior_function(bool prior_func)
{
mod_file->addStatement(make_unique<PriorPosteriorFunctionStatement>((bool) prior_func, options_list));
mod_file->addStatement(make_unique<PriorPosteriorFunctionStatement>(static_cast<bool>(prior_func), options_list));
options_list.clear();
}
......
......@@ -52,9 +52,9 @@ AbstractShocksStatement::writeDetShocks(ostream &output) const
const expr_t value = it.value;
output << "M_.det_shocks = [ M_.det_shocks;" << endl
<< "struct('exo_det'," << (int) exo_det
<< "struct('exo_det'," << static_cast<int>(exo_det)
<< ",'exo_id'," << id
<< ",'multiplicative'," << (int) mshocks
<< ",'multiplicative'," << static_cast<int>(mshocks)
<< ",'periods'," << period1 << ":" << period2
<< ",'value',";
value->writeOutput(output);
......
This diff is collapsed.
......@@ -330,13 +330,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 position of variable_number in the block number belonging to the block block_number
int
......
......@@ -354,7 +354,7 @@ TrendComponentModelTable::writeOutput(const string &basename, ostream &output) c
{
int eqn, lag, lhs_symb_id;
tie (eqn, lag, lhs_symb_id) = it.first;
int colidx = (int) distance(nontarget_lhs_vec.begin(), find(nontarget_lhs_vec.begin(), nontarget_lhs_vec.end(), lhs_symb_id));
int colidx = static_cast<int>(distance(nontarget_lhs_vec.begin(), find(nontarget_lhs_vec.begin(), nontarget_lhs_vec.end(), lhs_symb_id)));
ar_ec_output << " AR(" << eqn + 1 << ", " << colidx + 1 << ", " << lag << ") = ";
it.second->writeOutput(ar_ec_output, ExprNodeOutputType::matlabDynamicModel);
ar_ec_output << ";" << endl;
......@@ -527,7 +527,7 @@ VarModelTable::writeOutput(const string &basename, ostream &output) const
{
int eqn, lag, lhs_symb_id;
tie (eqn, lag, lhs_symb_id) = it.first;
int colidx = (int) distance(lhs.begin(), find(lhs.begin(), lhs.end(), lhs_symb_id));
int colidx = static_cast<int>(distance(lhs.begin(), find(lhs.begin(), lhs.end(), lhs_symb_id)));
ar_output << " ar(" << eqn + 1 << ", " << colidx + 1 << ", " << lag << ") = ";
it.second->writeOutput(ar_output, ExprNodeOutputType::matlabDynamicModel);
ar_output << ";" << endl;
......
......@@ -108,7 +108,7 @@ SymbolTable::freeze() noexcept(false)
frozen = true;
for (int i = 0; i < (int) symbol_table.size(); i++)
for (int i = 0; i < static_cast<int>(symbol_table.size()); i++)
{
int tsi;
switch (getType(i))
......@@ -168,22 +168,22 @@ SymbolTable::getID(SymbolType type, int tsid) const noexcept(false)
switch (type)
{
case SymbolType::endogenous:
if (tsid < 0 || tsid >= (int) endo_ids.size())
if (tsid < 0 || tsid >= static_cast<int>(endo_ids.size()))
throw UnknownTypeSpecificIDException(tsid, type);
else
return endo_ids[tsid];
case SymbolType::exogenous:
if (tsid < 0 || tsid >= (int) exo_ids.size())
if (tsid < 0 || tsid >= static_cast<int>(exo_ids.size()))
throw UnknownTypeSpecificIDException(tsid, type);
else
return exo_ids[tsid];
case SymbolType::exogenousDet:
if (tsid < 0 || tsid >= (int) exo_det_ids.size())
if (tsid < 0 || tsid >= static_cast<int>(exo_det_ids.size()))
throw UnknownTypeSpecificIDException(tsid, type);
else
return exo_det_ids[tsid];
case SymbolType::parameter:
if (tsid < 0 || tsid >= (int) param_ids.size())
if (tsid < 0 || tsid >= static_cast<int>(param_ids.size()))
throw UnknownTypeSpecificIDException(tsid, type);
else
return param_ids[tsid];
......@@ -347,7 +347,7 @@ SymbolTable::writeOutput(ostream &output) const noexcept(false)
if (aux_vars.size() == 0)
output << "M_.aux_vars = [];" << endl;
else
for (int i = 0; i < (int) aux_vars.size(); i++)
for (int i = 0; i < static_cast<int>(aux_vars.size()); i++)
{
output << "M_.aux_vars(" << i+1 << ").endo_index = " << getTypeSpecificID(aux_vars[i].get_symb_id())+1 << ";" << endl
<< "M_.aux_vars(" << i+1 << ").type = " << aux_vars[i].get_type_id() << ";" << endl;
......@@ -475,7 +475,7 @@ SymbolTable::writeCOutput(ostream &output) const noexcept(false)
if (aux_vars.size() > 0)
{
output << "struct aux_vars_t *av[" << aux_vars.size() << "];" << endl;
for (int i = 0; i < (int) aux_vars.size(); i++)
for (int i = 0; i < static_cast<int>(aux_vars.size()); i++)
{
output << "av[" << i << "].endo_index = " << getTypeSpecificID(aux_vars[i].get_symb_id()) << ";" << endl
<< "av[" << i << "].type = " << aux_vars[i].get_type_id() << ";" << endl;
......@@ -580,7 +580,7 @@ SymbolTable::writeCCOutput(ostream &output) const noexcept(false)
output << R"(param_names[")" << getName(param_ids[id]) << R"("] = )" << id << ";" << endl;
// Write the auxiliary variable table
for (int i = 0; i < (int) aux_vars.size(); i++)
for (int i = 0; i < static_cast<int>(aux_vars.size()); i++)
{
output << "aux_vars_t av" << i << ";" << endl;
output << "av" << i << ".endo_index = " << getTypeSpecificID(aux_vars[i].get_symb_id()) << ";" << endl
......@@ -987,7 +987,7 @@ SymbolTable::addObservedVariable(int symb_id) noexcept(false)
int
SymbolTable::observedVariablesNbr() const
{
return (int) varobs.size();
return static_cast<int>(varobs.size());
}
bool
......@@ -1001,7 +1001,7 @@ SymbolTable::getObservedVariableIndex(int symb_id) const
{
auto it = find(varobs.begin(), varobs.end(), symb_id);
assert(it != varobs.end());
return (int) (it - varobs.begin());
return static_cast<int>(it - varobs.begin());
}
void
......@@ -1015,7 +1015,7 @@ SymbolTable::addObservedExogenousVariable(int symb_id) noexcept(false)
int
SymbolTable::observedExogenousVariablesNbr() const
{
return (int) varexobs.size();
return static_cast<int>(varexobs.size());
}
bool
......@@ -1029,7 +1029,7 @@ SymbolTable::getObservedExogenousVariableIndex(int symb_id) const
{
auto it = find(varexobs.begin(), varexobs.end(), symb_id);
assert(it != varexobs.end());
return (int) (it - varexobs.begin());
return static_cast<int>(it - varexobs.begin());
}
vector <int>
......
......@@ -422,7 +422,7 @@ public:
inline void
SymbolTable::validateSymbID(int symb_id) const noexcept(false)
{
if (symb_id < 0 || symb_id > (int) symbol_table.size())
if (symb_id < 0 || symb_id > static_cast<int>(symbol_table.size()))
throw UnknownSymbolIDException(symb_id);
}
......
......@@ -356,7 +356,7 @@ MacroDriver::begin_if(const MacroValuePtr &value) noexcept(false)
auto ival = dynamic_pointer_cast<IntMV>(value);
if (!ival)
throw MacroValue::TypeError("Argument of @#if must be an integer");
last_if = (bool) ival->value;
last_if = static_cast<bool>(ival->value);
}
void
......
......@@ -19,5 +19,7 @@ libmacro_a_CPPFLAGS = $(BOOST_CPPFLAGS) -I..
MacroFlex.cc: MacroFlex.ll
$(LEX) -o MacroFlex.cc MacroFlex.ll
libmacro_a-MacroFlex.$(OBJEXT): CXXFLAGS += -Wno-old-style-cast
MacroBison.cc MacroBison.hh location.hh stack.hh position.hh: MacroBison.yy
$(YACC) -W -o MacroBison.cc MacroBison.yy
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment