]>
Commit | Line | Data |
---|---|---|
213516ef | 1 | dnl Copyright (C) 1997-2023 Free Software Foundation, Inc. |
760b3e8b MF |
2 | dnl |
3 | dnl This program is free software; you can redistribute it and/or modify | |
4 | dnl it under the terms of the GNU General Public License as published by | |
5 | dnl the Free Software Foundation; either version 3 of the License, or | |
6 | dnl (at your option) any later version. | |
7 | dnl | |
8 | dnl This program is distributed in the hope that it will be useful, | |
9 | dnl but WITHOUT ANY WARRANTY; without even the implied warranty of | |
10 | dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
11 | dnl GNU General Public License for more details. | |
12 | dnl | |
13 | dnl You should have received a copy of the GNU General Public License | |
14 | dnl along with this program. If not, see <http://www.gnu.org/licenses/>. | |
15 | dnl | |
16 | dnl --enable-build-warnings is for developers of the simulator. | |
17 | dnl it enables extra GCC specific warnings. | |
3c7666dc | 18 | AC_DEFUN([SIM_AC_OPTION_WARNINGS], [dnl |
760b3e8b MF |
19 | AC_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 |
27 | dnl Enable -Werror by default when using gcc. Turn it off for releases. |
28 | if test "${GCC}" = yes -a -z "${ERROR_ON_WARNING}" && $development; then | |
982c3a65 | 29 | ERROR_ON_WARNING=yes |
760b3e8b MF |
30 | fi |
31 | ||
32 | WERROR_CFLAGS="" | |
982c3a65 MF |
33 | if test "${ERROR_ON_WARNING}" = yes ; then |
34 | WERROR_CFLAGS="-Werror" | |
35 | fi | |
760b3e8b | 36 | |
3167423f MF |
37 | dnl The options we'll try to enable. |
38 | dnl NB: Kept somewhat in sync with gdbsupport/warnings.m4. | |
b0c06375 | 39 | build_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 |
44 | dnl C++ -Wno-mismatched-tags | |
45 | -Wno-error=deprecated-register | |
46 | dnl C++ -Wsuggest-override | |
47 | dnl C++ -Wdeprecated-copy | |
48 | dnl C++ -Wdeprecated-copy-dtor | |
49 | dnl C++ -Wredundant-move | |
7f6fa743 | 50 | -Wmissing-declarations |
b0c06375 MF |
51 | dnl C++ -Wstrict-null-sentinel |
52 | " | |
53 | dnl Some extra warnings we use in the sim. | |
54 | build_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 |
67 | dnl The cgen virtual insn logic involves enum conversions. |
68 | dnl Disable until we can figure out how to make this work. | |
69 | -Wno-enum-conversion | |
7f6fa743 | 70 | " |
760b3e8b | 71 | |
760b3e8b | 72 | case "${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 |
87 | esac |
88 | ||
89 | AC_ARG_ENABLE(build-warnings, | |
90 | AS_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"`;; | |
99 | esac | |
100 | if test x"$silent" != x"yes" && test x"$build_warnings" != x""; then | |
101 | echo "Setting compiler warning flags = $build_warnings" 6>&1 | |
102 | fi])dnl | |
103 | AC_ARG_ENABLE(sim-build-warnings, | |
104 | AS_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"`;; | |
113 | esac | |
114 | if test x"$silent" != x"yes" && test x"$build_warnings" != x""; then | |
115 | echo "Setting GDB specific compiler warning flags = $build_warnings" 6>&1 | |
116 | fi])dnl | |
117 | WARN_CFLAGS="" | |
118 | if test "x${build_warnings}" != x -a "x$GCC" = xyes | |
119 | then | |
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}) | |
150 | fi | |
151 | ]) | |
152 | AC_SUBST(WARN_CFLAGS) | |
153 | AC_SUBST(WERROR_CFLAGS) |