From 888a87312dfb1943a08c3dab3e01c11053dcdd9d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Villemot?= <sebastien@dynare.org> Date: Tue, 5 Jul 2022 12:12:53 +0200 Subject: [PATCH] Enable -Wunused-parameter for C++ MEX Except for libdynare++, since Dynare++ is not ready (and is probably not worth fixing by adding [[maybe_unused]] tags). --- mex/build/libdynare++.am | 3 ++- mex/build/matlab/mex.am | 2 +- mex/build/octave/mex.am | 2 +- .../block_kalman_filter/block_kalman_filter.cc | 11 ++++++----- .../block_kalman_filter/block_kalman_filter.hh | 4 ++-- mex/sources/k_order_perturbation/k_ord_dynare.cc | 11 +++++++---- mex/sources/num_procs/num_procs.cc | 4 ++-- 7 files changed, 21 insertions(+), 16 deletions(-) diff --git a/mex/build/libdynare++.am b/mex/build/libdynare++.am index e20eca1087..8fceeb334b 100644 --- a/mex/build/libdynare++.am +++ b/mex/build/libdynare++.am @@ -4,7 +4,8 @@ TOPDIR = $(top_srcdir)/../../../dynare++ libdynare___a_CPPFLAGS = $(AM_CPPFLAGS) -I$(TOPDIR)/src -I$(TOPDIR)/kord -I$(TOPDIR)/tl/cc -I$(TOPDIR)/utils/cc -I$(TOPDIR)/sylv/cc -I$(TOPDIR)/integ/cc $(CPPFLAGS_MATIO) -libdynare___a_CXXFLAGS = $(AM_CXXFLAGS) $(THREAD_CXXFLAGS) +# TODO: Remove -Wno-unused-parameter once the same has been done for Dynare++ +libdynare___a_CXXFLAGS = $(AM_CXXFLAGS) $(THREAD_CXXFLAGS) -Wno-unused-parameter KORD_SRCS = \ approximation.cc \ diff --git a/mex/build/matlab/mex.am b/mex/build/matlab/mex.am index 647bec4cc3..237762aec6 100644 --- a/mex/build/matlab/mex.am +++ b/mex/build/matlab/mex.am @@ -9,7 +9,7 @@ DEFS += -DMEXEXT=\"$(MEXEXT)\" AM_CFLAGS = $(MATLAB_CFLAGS) -Wall -Wno-parentheses # TODO: use same warnings as C++ AM_FCFLAGS = $(MATLAB_FCFLAGS) -Wall -Wimplicit-interface -AM_CXXFLAGS = -std=gnu++20 $(MATLAB_CXXFLAGS) -Wall -Wno-dangling-else -Wextra -Wno-unused-parameter -Wold-style-cast +AM_CXXFLAGS = -std=gnu++20 $(MATLAB_CXXFLAGS) -Wall -Wno-dangling-else -Wextra -Wold-style-cast AM_LDFLAGS = $(MATLAB_LDFLAGS) LIBS += $(MATLAB_LIBS) diff --git a/mex/build/octave/mex.am b/mex/build/octave/mex.am index a5e126b9a2..7bd3e2c537 100644 --- a/mex/build/octave/mex.am +++ b/mex/build/octave/mex.am @@ -7,7 +7,7 @@ DEFS += -DMEXEXT=\".mex\" AM_CFLAGS = $(shell $(MKOCTFILE) -p CPICFLAG) -Wall -Wno-parentheses # TODO: use same warnings as C++ AM_FCFLAGS = $(shell $(MKOCTFILE) -p FPICFLAG) -Wall -Wimplicit-interface -AM_CXXFLAGS = -std=gnu++20 $(shell $(MKOCTFILE) -p CXXPICFLAG) -Wall -Wno-dangling-else -Wextra -Wno-unused-parameter -Wold-style-cast +AM_CXXFLAGS = -std=gnu++20 $(shell $(MKOCTFILE) -p CXXPICFLAG) -Wall -Wno-dangling-else -Wextra -Wold-style-cast AM_LDFLAGS = $(shell $(MKOCTFILE) -p DL_LDFLAGS) # See the comments in configure.ac diff --git a/mex/sources/block_kalman_filter/block_kalman_filter.cc b/mex/sources/block_kalman_filter/block_kalman_filter.cc index e6ea916cc1..536d8c1407 100644 --- a/mex/sources/block_kalman_filter/block_kalman_filter.cc +++ b/mex/sources/block_kalman_filter/block_kalman_filter.cc @@ -1,5 +1,5 @@ /* - * Copyright © 2007-2020 Dynare Team + * Copyright © 2007-2022 Dynare Team * * This file is part of Dynare. * @@ -141,10 +141,8 @@ det(const double *F, int dim, const lapack_int *ipiv) return det; } -BlockKalmanFilter::BlockKalmanFilter(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) +BlockKalmanFilter::BlockKalmanFilter(int nrhs, const mxArray *prhs[]) { - if (nlhs > 2) - mexErrMsgTxt("block_kalman_filter provides at most 2 output argument."); if (nrhs != 13 && nrhs != 16) mexErrMsgTxt("block_kalman_filter requires exactly \n 13 input arguments for standard Kalman filter \nor\n 16 input arguments for missing observations Kalman filter."); if (nrhs == 16) @@ -817,6 +815,9 @@ BlockKalmanFilter::block_kalman_filter(int nlhs, mxArray *plhs[]) void BlockKalmanFilter::return_results_and_clean(int nlhs, mxArray *plhs[]) { + if (nlhs > 2) + mexErrMsgTxt("block_kalman_filter provides at most 2 output argument."); + if (nlhs >= 1) { plhs[0] = mxCreateDoubleMatrix(1, 1, mxREAL); @@ -843,7 +844,7 @@ BlockKalmanFilter::return_results_and_clean(int nlhs, mxArray *plhs[]) void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) { - BlockKalmanFilter block_kalman_filter(nlhs, plhs, nrhs, prhs); + BlockKalmanFilter block_kalman_filter(nrhs, prhs); if (block_kalman_filter.block_kalman_filter(nlhs, plhs)) block_kalman_filter.return_results_and_clean(nlhs, plhs); } diff --git a/mex/sources/block_kalman_filter/block_kalman_filter.hh b/mex/sources/block_kalman_filter/block_kalman_filter.hh index 8ea8e57371..8687e92a70 100644 --- a/mex/sources/block_kalman_filter/block_kalman_filter.hh +++ b/mex/sources/block_kalman_filter/block_kalman_filter.hh @@ -1,5 +1,5 @@ /* - * Copyright © 2007-2019 Dynare Team + * Copyright © 2007-2022 Dynare Team * * This file is part of Dynare. * @@ -60,7 +60,7 @@ public: double *dd_index; double *K, *a, *K_P, *P_t_t1, *tmp, *P; public: - BlockKalmanFilter(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]); + BlockKalmanFilter(int nrhs, const mxArray *prhs[]); bool block_kalman_filter(int nlhs, mxArray *plhs[]); void block_kalman_filter_ss(); void return_results_and_clean(int nlhs, mxArray *plhs[]); diff --git a/mex/sources/k_order_perturbation/k_ord_dynare.cc b/mex/sources/k_order_perturbation/k_ord_dynare.cc index 63bb7d0a68..1ffbb2f3f2 100644 --- a/mex/sources/k_order_perturbation/k_ord_dynare.cc +++ b/mex/sources/k_order_perturbation/k_ord_dynare.cc @@ -1,5 +1,5 @@ /* - * Copyright © 2008-2021 Dynare Team + * Copyright © 2008-2022 Dynare Team * * This file is part of Dynare. * @@ -52,15 +52,18 @@ KordpDynare::solveDeterministicSteady() } void -KordpDynare::evaluateSystem(Vector &out, const ConstVector &yy, const Vector &xx) +KordpDynare::evaluateSystem(Vector &out, [[maybe_unused]] const ConstVector &yy, + [[maybe_unused]] const Vector &xx) { // This method is only called when checking the residuals at steady state (Approximation::check), so return zero residuals out.zeros(); } void -KordpDynare::evaluateSystem(Vector &out, const ConstVector &yym, const ConstVector &yy, - const ConstVector &yyp, const Vector &xx) +KordpDynare::evaluateSystem(Vector &out, [[maybe_unused]] const ConstVector &yym, + [[maybe_unused]] const ConstVector &yy, + [[maybe_unused]] const ConstVector &yyp, + [[maybe_unused]] const Vector &xx) { // This method is only called when checking the residuals at steady state (Approximation::check), so return zero residuals out.zeros(); diff --git a/mex/sources/num_procs/num_procs.cc b/mex/sources/num_procs/num_procs.cc index 40e69da705..15b99a6861 100644 --- a/mex/sources/num_procs/num_procs.cc +++ b/mex/sources/num_procs/num_procs.cc @@ -1,5 +1,5 @@ /* - * Copyright © 2019 Dynare Team + * Copyright © 2019-2022 Dynare Team * * This file is part of Dynare. * @@ -23,7 +23,7 @@ void mexFunction(int nlhs, mxArray *plhs[], - int nrhs, const mxArray *prhs[]) + int nrhs, [[maybe_unused]] const mxArray *prhs[]) { if (nrhs != 0 || nlhs != 1) mexErrMsgTxt("Must have zero input argument and one output argument"); -- GitLab