aboutsummaryrefslogtreecommitdiff
path: root/sim/m4
diff options
context:
space:
mode:
authorMike Frysinger <vapier@gentoo.org>2023-12-23 01:00:08 -0500
committerMike Frysinger <vapier@gentoo.org>2023-12-23 01:21:23 -0500
commit4da6be3f1ad66987b7e072e578183798b3c29cb0 (patch)
tree835539aec6651d2ff2058ec97bb9034bf13657e0 /sim/m4
parent576d2c97d8de26d1ab5a2058e8ba4ffd00b8096d (diff)
downloadbinutils-4da6be3f1ad66987b7e072e578183798b3c29cb0.zip
binutils-4da6be3f1ad66987b7e072e578183798b3c29cb0.tar.gz
binutils-4da6be3f1ad66987b7e072e578183798b3c29cb0.tar.bz2
sim: warnings: rework individual flag disable into dedicated vars
The -Wshadow=local is too new for some compilers, so move it to a var that we test at configure time.
Diffstat (limited to 'sim/m4')
-rw-r--r--sim/m4/sim_ac_option_warnings.m466
1 files changed, 45 insertions, 21 deletions
diff --git a/sim/m4/sim_ac_option_warnings.m4 b/sim/m4/sim_ac_option_warnings.m4
index 1c2d091..02b5ffa 100644
--- a/sim/m4/sim_ac_option_warnings.m4
+++ b/sim/m4/sim_ac_option_warnings.m4
@@ -128,33 +128,57 @@ then
# Separate out the -Werror flag as some files just cannot be
# compiled with it enabled.
for w in ${build_warnings}; do
- # GCC does not complain about -Wno-unknown-warning. Invert
- # and test -Wunknown-warning instead.
- case $w in
- -Wno-*)
- wtest=`echo $w | sed 's/-Wno-/-W/g'` ;;
- -Wformat-nonliteral)
- # gcc requires -Wformat before -Wformat-nonliteral
- # will work, so stick them together.
- w="-Wformat $w"
- wtest="$w"
- ;;
- *)
- wtest=$w ;;
- esac
-
case $w in
-Werr*) WERROR_CFLAGS=-Werror ;;
- *)
- # Check whether GCC accepts it.
- saved_CFLAGS="$CFLAGS"
- CFLAGS="$CFLAGS -Werror $wtest"
- AC_TRY_COMPILE([],[],WARN_CFLAGS="${WARN_CFLAGS} $w",)
- CFLAGS="$saved_CFLAGS"
+ *) _SIM_TEST_WARNING_FLAG($w, [WARN_CFLAGS="${WARN_CFLAGS} $w"]) ;;
esac
done
AC_MSG_RESULT(${WARN_CFLAGS} ${WERROR_CFLAGS})
+
+ dnl Test individual flags to export to dedicated variables.
+ m4_map([_SIM_EXPORT_WARNING_FLAG], m4_split(m4_normalize([
+ -Wno-shadow=local
+ -Wno-unused-but-set-variable
+ ])))dnl
fi
])
+dnl Test a warning flag $1 and execute $2 if it passes, else $3.
+AC_DEFUN([_SIM_TEST_WARNING_FLAG], [dnl
+ dnl GCC does not complain about -Wno-unknown-warning. Invert
+ dnl and test -Wunknown-warning instead.
+ w="$1"
+ case $w in
+ -Wno-*)
+ wtest=`echo $w | sed 's/-Wno-/-W/g'` ;;
+ -Wformat-nonliteral)
+ dnl gcc requires -Wformat before -Wformat-nonliteral
+ dnl will work, so stick them together.
+ w="-Wformat $w"
+ wtest="$w"
+ ;;
+ *)
+ wtest=$w ;;
+ esac
+
+ dnl Check whether GCC accepts it.
+ saved_CFLAGS="$CFLAGS"
+ CFLAGS="$CFLAGS -Werror $wtest"
+ AC_TRY_COMPILE([],[],$2,$3)
+ CFLAGS="$saved_CFLAGS"
+])
+dnl Export variable $1 to $2 for use in makefiles.
+AC_DEFUN([_SIM_EXPORT_WARNING], [dnl
+ AS_VAR_SET($1, $2)
+ AC_SUBST($1)
+])
+dnl Test if $1 is a known warning flag, and export a variable for makefiles.
+dnl If $1=-Wfoo, then SIM_CFLAG_WFOO will be set to -Wfoo if it's supported.
+AC_DEFUN([_SIM_EXPORT_WARNING_FLAG], [dnl
+ AC_MSG_CHECKING([whether $1 is supported])
+ _SIM_TEST_WARNING_FLAG($1, [dnl
+ _SIM_EXPORT_WARNING([SIM_CFLAG]m4_toupper(m4_translit($1, [-= ], [__])), $1)
+ AC_MSG_RESULT(yes)
+ ], [AC_MSG_RESULT(no)])
+])
AC_SUBST(WARN_CFLAGS)
AC_SUBST(WERROR_CFLAGS)