public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] sim: ppc: unify (most) compiler warnings with common code
@ 2021-06-30 18:40 Mike Frysinger
  0 siblings, 0 replies; only message in thread
From: Mike Frysinger @ 2021-06-30 18:40 UTC (permalink / raw)
  To: gdb-patches

Copy most of the common build warning logic over from the common
code to help keep code behavior a bit consistent, and turn them
on by default.  We disable a few flags for now until we can clean
the code up.
---
 sim/ppc/configure    | 43 ++++++++++++++++++++++++++++++++++++++++---
 sim/ppc/configure.ac | 29 +++++++++++++++++++++++++++--
 2 files changed, 67 insertions(+), 5 deletions(-)

diff --git a/sim/ppc/configure.ac b/sim/ppc/configure.ac
index 30952f30a4af..a7d226df5cf6 100644
--- a/sim/ppc/configure.ac
+++ b/sim/ppc/configure.ac
@@ -430,16 +430,41 @@ if test x"$silent" != x"yes" && test x"$sim_timebase" != x""; then
 fi],[sim_timebase=""])dnl
 
 
+dnl TODO: Switch to common $(WARN_CFLAGS).
+sim_warnings="-Wall -Wdeclaration-after-statement -Wpointer-arith
+-Wno-unused -Wunused-value -Wunused-function
+-Wno-switch -Wno-char-subscripts
+-Wempty-body -Wunused-but-set-parameter
+-Wno-error=maybe-uninitialized
+-Wno-missing-declarations
+-Wno-missing-prototypes
+-Wdeclaration-after-statement -Wmissing-parameter-type
+-Wno-pointer-sign
+-Wold-style-declaration -Wold-style-definition
+"
 AC_ARG_ENABLE(sim-warnings,
 [  --enable-sim-warnings=opts		Extra CFLAGS for turning on compiler warnings except for idecode.o, semantics.o and psim.o],
 [case "${enableval}" in
-  yes)	sim_warnings="-Werror -Wall -Wpointer-arith -Wmissing-prototypes -Wmissing-declarations ";;
+  yes)	;;
   no)	sim_warnings="-w";;
   *)	sim_warnings=`echo "${enableval}" | sed -e "s/,/ /g"`;;
 esac
 if test x"$silent" != x"yes" && test x"$sim_warnings" != x""; then
   echo "Setting warning flags = $sim_warnings" 6>&1
-fi],[sim_warnings=""])dnl
+fi])dnl
+if test "x${sim_warnings}" != x -a "x$GCC" = xyes; then
+  AC_MSG_CHECKING(compiler warning flags)
+  build_warnings="${sim_warnings}"
+  sim_warnings=
+  for w in ${build_warnings}; do
+    dnl Check that GCC accepts it
+    saved_CFLAGS="$CFLAGS"
+    CFLAGS="$CFLAGS -Werror $w"
+    AC_TRY_COMPILE([],[],sim_warnings="${sim_warnings} $w",)
+    CFLAGS="$saved_CFLAGS"
+  done
+  AC_MSG_RESULT(${sim_warnings})
+fi
 
 
 AC_ARG_ENABLE(sim-xor-endian,
-- 
2.31.1


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-06-30 18:40 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-30 18:40 [PATCH] sim: ppc: unify (most) compiler warnings with common code Mike Frysinger

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).