Fix -Wno-unknown-warning support detection
authorPedro Alves <palves@redhat.com>
Wed, 16 Dec 2015 22:56:48 +0000 (22:56 +0000)
committerPedro Alves <palves@redhat.com>
Wed, 16 Dec 2015 22:56:49 +0000 (22:56 +0000)
Ref: https://sourceware.org/ml/gdb/2015-12/msg00024.html

We have code in configure.ac that tries to detect whether the compiler
supports each warning and suppress it if not, but that doesn't work
with "-Wno-" options, because gcc doesn't error out for
-Wno-unknown-warning unless other diagnostics are being produced.

See https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html.

Handle this by checking whether -Wfoo works when we actually want
-Wno-foo.

gdb/ChangeLog:
2015-12-16  Pedro Alves  <palves@redhat.com>

* configure.ac (compiler warning flags): When testing a
-Wno-foo option, check whether -Wfoo works instead.
* configure: Regenerate.

gdb/gdbserver/ChangeLog:
2015-12-16  Pedro Alves  <palves@redhat.com>

* configure.ac (compiler warning flags): When testing a
-Wno-foo option, check whether -Wfoo works instead.
* configure: Regenerate.

gdb/ChangeLog
gdb/configure
gdb/configure.ac
gdb/gdbserver/ChangeLog
gdb/gdbserver/configure
gdb/gdbserver/configure.ac

index fcb0e3035fb37bc4708d479c85104f893f75e28a..4d75eeaee248b3bdcf341d1fb33fd330560c7998 100644 (file)
@@ -1,3 +1,9 @@
+2015-12-16  Pedro Alves  <palves@redhat.com>
+
+       * configure.ac (compiler warning flags): When testing a
+       -Wno-foo option, check whether -Wfoo works instead.
+       * configure: Regenerate.
+
 2015-12-16  Pedro Alves  <palves@redhat.com>
 
        * common/vec.h (vec_offset): New macro.
index 249a39975b027e6fad0f550282e8df2a3aa4ddb9..4c308cb2c6853d9aa5561d13af3fbd079b316cc5 100755 (executable)
@@ -14376,14 +14376,23 @@ $as_echo_n "checking compiler warning flags... " >&6; }
     # 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'` ;;
+       *)
+               wtest=$w ;;
+       esac
+
        case $w in
        -Werr*) WERROR_CFLAGS=-Werror ;;
        *)
            # Check whether GCC accepts it.
            saved_CFLAGS="$CFLAGS"
-           CFLAGS="$CFLAGS $w"
+           CFLAGS="$CFLAGS $wtest"
            saved_CXXFLAGS="$CXXFLAGS"
-           CXXFLAGS="$CXXFLAGS $w"
+           CXXFLAGS="$CXXFLAGS $wtest"
            cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 
index ebd797bf51940c614b295e24e5a2b37998cabf89..b9d8f8bca57b9de20f0fe42e8f58bdc0699dad4a 100644 (file)
@@ -2007,14 +2007,23 @@ 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'` ;;
+       *)
+               wtest=$w ;;
+       esac
+
        case $w in
        -Werr*) WERROR_CFLAGS=-Werror ;;
        *)
            # Check whether GCC accepts it.
            saved_CFLAGS="$CFLAGS"
-           CFLAGS="$CFLAGS $w"
+           CFLAGS="$CFLAGS $wtest"
            saved_CXXFLAGS="$CXXFLAGS"
-           CXXFLAGS="$CXXFLAGS $w"
+           CXXFLAGS="$CXXFLAGS $wtest"
            AC_TRY_COMPILE([],[],WARN_CFLAGS="${WARN_CFLAGS} $w",)
            CFLAGS="$saved_CFLAGS"
            CXXFLAGS="$saved_CXXFLAGS"
index 63bb2503a2100db3c9d33cbc451592932b622403..d54bb7404d99ec15442d59beb9c116d4d51ed00d 100644 (file)
@@ -1,3 +1,9 @@
+2015-12-16  Pedro Alves  <palves@redhat.com>
+
+       * configure.ac (compiler warning flags): When testing a
+       -Wno-foo option, check whether -Wfoo works instead.
+       * configure: Regenerate.
+
 2015-12-11  Don Breazeal  <donb@codesourcery.com>
 
        * server.c (process_serial_event): Don't exit from gdbserver
index ccb9639d5208460b5b68c2528805634835446c7f..ab03cacfe9f630bf192edb881d07bcd2cd138e9e 100755 (executable)
@@ -6148,14 +6148,23 @@ $as_echo_n "checking compiler warning flags... " >&6; }
     # 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'` ;;
+       *)
+               wtest=$w ;;
+       esac
+
        case $w in
        -Werr*) WERROR_CFLAGS=-Werror ;;
        *)
            # Check whether GCC accepts it.
            saved_CFLAGS="$CFLAGS"
-           CFLAGS="$CFLAGS $w"
+           CFLAGS="$CFLAGS $wtest"
            saved_CXXFLAGS="$CXXFLAGS"
-           CXXFLAGS="$CXXFLAGS $w"
+           CXXFLAGS="$CXXFLAGS $wtest"
            cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 
index 5524a052c6195052631e05cf2676c02f736548fc..6caf91c43a16369b2dd6e9b7790a8581699bd902 100644 (file)
@@ -193,14 +193,23 @@ 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'` ;;
+       *)
+               wtest=$w ;;
+       esac
+
        case $w in
        -Werr*) WERROR_CFLAGS=-Werror ;;
        *)
            # Check whether GCC accepts it.
            saved_CFLAGS="$CFLAGS"
-           CFLAGS="$CFLAGS $w"
+           CFLAGS="$CFLAGS $wtest"
            saved_CXXFLAGS="$CXXFLAGS"
-           CXXFLAGS="$CXXFLAGS $w"
+           CXXFLAGS="$CXXFLAGS $wtest"
            AC_TRY_COMPILE([],[],WARN_CFLAGS="${WARN_CFLAGS} $w",)
            CFLAGS="$saved_CFLAGS"
            CXXFLAGS="$saved_CXXFLAGS"