]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - sim/m4/sim_ac_option_warnings.m4
sim: warnings: disable -Wenum-conversion fow now [PR sim/29752]
[thirdparty/binutils-gdb.git] / sim / m4 / sim_ac_option_warnings.m4
CommitLineData
213516ef 1dnl Copyright (C) 1997-2023 Free Software Foundation, Inc.
760b3e8b
MF
2dnl
3dnl This program is free software; you can redistribute it and/or modify
4dnl it under the terms of the GNU General Public License as published by
5dnl the Free Software Foundation; either version 3 of the License, or
6dnl (at your option) any later version.
7dnl
8dnl This program is distributed in the hope that it will be useful,
9dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
10dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11dnl GNU General Public License for more details.
12dnl
13dnl You should have received a copy of the GNU General Public License
14dnl along with this program. If not, see <http://www.gnu.org/licenses/>.
15dnl
16dnl --enable-build-warnings is for developers of the simulator.
17dnl it enables extra GCC specific warnings.
3c7666dc 18AC_DEFUN([SIM_AC_OPTION_WARNINGS], [dnl
760b3e8b
MF
19AC_ARG_ENABLE(werror,
20 AS_HELP_STRING([--enable-werror], [treat compile warnings as errors]),
21 [case "${enableval}" in
22 yes | y) ERROR_ON_WARNING="yes" ;;
23 no | n) ERROR_ON_WARNING="no" ;;
24 *) AC_MSG_ERROR(bad value ${enableval} for --enable-werror) ;;
25 esac])
26
ab18008e
MF
27dnl Enable -Werror by default when using gcc. Turn it off for releases.
28if test "${GCC}" = yes -a -z "${ERROR_ON_WARNING}" && $development; then
982c3a65 29 ERROR_ON_WARNING=yes
760b3e8b
MF
30fi
31
32WERROR_CFLAGS=""
982c3a65
MF
33if test "${ERROR_ON_WARNING}" = yes ; then
34 WERROR_CFLAGS="-Werror"
35fi
760b3e8b 36
3167423f
MF
37dnl The options we'll try to enable.
38dnl NB: Kept somewhat in sync with gdbsupport/warnings.m4.
b0c06375 39build_warnings="-Wall -Wpointer-arith
7f6fa743
MF
40-Wno-unused -Wunused-value -Wunused-function
41-Wno-switch -Wno-char-subscripts
42-Wempty-body -Wunused-but-set-parameter
b0c06375
MF
43-Wno-sign-compare -Wno-error=maybe-uninitialized
44dnl C++ -Wno-mismatched-tags
45-Wno-error=deprecated-register
46dnl C++ -Wsuggest-override
47dnl C++ -Wdeprecated-copy
48dnl C++ -Wdeprecated-copy-dtor
49dnl C++ -Wredundant-move
7f6fa743 50-Wmissing-declarations
b0c06375
MF
51dnl C++ -Wstrict-null-sentinel
52"
53dnl Some extra warnings we use in the sim.
54build_warnings="$build_warnings
55-Wdeclaration-after-statement
56-Wdeprecated-non-prototype
57-Wimplicit-function-declaration
58-Wimplicit-int
59-Wincompatible-function-pointer-types
60-Wincompatible-pointer-types
61-Wmisleading-indentation
62-Wmissing-parameter-type
7f6fa743 63-Wmissing-prototypes
b0c06375
MF
64-Wold-style-declaration
65-Wold-style-definition
7f6fa743 66-Wpointer-sign
a7292455
MF
67dnl The cgen virtual insn logic involves enum conversions.
68dnl Disable until we can figure out how to make this work.
69-Wno-enum-conversion
7f6fa743 70"
760b3e8b 71
760b3e8b 72case "${host}" in
3c7666dc
MF
73 *-*-mingw32*)
74 # Enable -Wno-format by default when using gcc on mingw since many
75 # GCC versions complain about %I64.
76 build_warnings="$build_warnings -Wno-format" ;;
77 *-*-solaris*)
78 # Solaris 11.4 <python2.7/ceval.h> uses #pragma no_inline that GCC
79 # doesn't understand.
80 build_warnings="$build_warnings -Wno-unknown-pragmas"
81 # Solaris 11 <unistd.h> marks vfork deprecated.
82 build_warnings="$build_warnings -Wno-deprecated-declarations" ;;
83 *)
84 # Note that gcc requires -Wformat for -Wformat-nonliteral to work,
85 # but there's a special case for this below.
86 build_warnings="$build_warnings -Wformat-nonliteral" ;;
760b3e8b
MF
87esac
88
89AC_ARG_ENABLE(build-warnings,
90AS_HELP_STRING([--enable-build-warnings], [enable build-time compiler warnings if gcc is used]),
91[case "${enableval}" in
92 yes) ;;
93 no) build_warnings="-w";;
94 ,*) t=`echo "${enableval}" | sed -e "s/,/ /g"`
95 build_warnings="${build_warnings} ${t}";;
96 *,) t=`echo "${enableval}" | sed -e "s/,/ /g"`
97 build_warnings="${t} ${build_warnings}";;
98 *) build_warnings=`echo "${enableval}" | sed -e "s/,/ /g"`;;
99esac
100if test x"$silent" != x"yes" && test x"$build_warnings" != x""; then
101 echo "Setting compiler warning flags = $build_warnings" 6>&1
102fi])dnl
103AC_ARG_ENABLE(sim-build-warnings,
104AS_HELP_STRING([--enable-sim-build-warnings], [enable SIM specific build-time compiler warnings if gcc is used]),
105[case "${enableval}" in
106 yes) ;;
107 no) build_warnings="-w";;
108 ,*) t=`echo "${enableval}" | sed -e "s/,/ /g"`
109 build_warnings="${build_warnings} ${t}";;
110 *,) t=`echo "${enableval}" | sed -e "s/,/ /g"`
111 build_warnings="${t} ${build_warnings}";;
112 *) build_warnings=`echo "${enableval}" | sed -e "s/,/ /g"`;;
113esac
114if test x"$silent" != x"yes" && test x"$build_warnings" != x""; then
115 echo "Setting GDB specific compiler warning flags = $build_warnings" 6>&1
116fi])dnl
117WARN_CFLAGS=""
118if test "x${build_warnings}" != x -a "x$GCC" = xyes
119then
120 AC_MSG_CHECKING(compiler warning flags)
121 # Separate out the -Werror flag as some files just cannot be
122 # compiled with it enabled.
123 for w in ${build_warnings}; do
3c7666dc
MF
124 # GCC does not complain about -Wno-unknown-warning. Invert
125 # and test -Wunknown-warning instead.
126 case $w in
127 -Wno-*)
128 wtest=`echo $w | sed 's/-Wno-/-W/g'` ;;
129 -Wformat-nonliteral)
130 # gcc requires -Wformat before -Wformat-nonliteral
131 # will work, so stick them together.
132 w="-Wformat $w"
133 wtest="$w"
134 ;;
135 *)
136 wtest=$w ;;
137 esac
138
760b3e8b
MF
139 case $w in
140 -Werr*) WERROR_CFLAGS=-Werror ;;
3c7666dc
MF
141 *)
142 # Check whether GCC accepts it.
760b3e8b 143 saved_CFLAGS="$CFLAGS"
3c7666dc 144 CFLAGS="$CFLAGS -Werror $wtest"
760b3e8b
MF
145 AC_TRY_COMPILE([],[],WARN_CFLAGS="${WARN_CFLAGS} $w",)
146 CFLAGS="$saved_CFLAGS"
147 esac
148 done
149 AC_MSG_RESULT(${WARN_CFLAGS} ${WERROR_CFLAGS})
150fi
151])
152AC_SUBST(WARN_CFLAGS)
153AC_SUBST(WERROR_CFLAGS)