]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blobdiff - gdb/warning.m4
Add -Wunused-variable to warnings.m4
[thirdparty/binutils-gdb.git] / gdb / warning.m4
index 632cc214ac0bf693bdf9f1da1f73cf6410f7776c..00e7cd60508c42262762786ac7bf5e74d0e29207 100644 (file)
@@ -37,7 +37,7 @@ fi
 
 # The options we'll try to enable.
 build_warnings="-Wall -Wpointer-arith \
--Wno-unused -Wunused-value -Wunused-function \
+-Wno-unused -Wunused-value -Wunused-variable -Wunused-function \
 -Wno-switch -Wno-char-subscripts \
 -Wempty-body -Wunused-but-set-parameter -Wunused-but-set-variable \
 -Wno-sign-compare -Wno-narrowing -Wno-error=maybe-uninitialized \
@@ -118,7 +118,20 @@ then
            CFLAGS="$CFLAGS -Werror $wtest"
            saved_CXXFLAGS="$CXXFLAGS"
            CXXFLAGS="$CXXFLAGS -Werror $wtest"
-           AC_TRY_COMPILE([],[],WARN_CFLAGS="${WARN_CFLAGS} $w",)
+           if test "x$w" = "x-Wunused-variable"; then
+             # Check for https://gcc.gnu.org/bugzilla/show_bug.cgi?id=38958,
+             # fixed in GCC 4.9.  This test is derived from the gdb
+             # source code that triggered this bug in GCC.
+             AC_TRY_COMPILE(
+               [struct scoped_restore_base {};
+                 struct scoped_restore_tmpl : public scoped_restore_base {
+                  ~scoped_restore_tmpl() {}
+                };],
+               [const scoped_restore_base &b = scoped_restore_tmpl();],
+               WARN_CFLAGS="${WARN_CFLAGS} $w",)
+           else
+             AC_TRY_COMPILE([],[],WARN_CFLAGS="${WARN_CFLAGS} $w",)
+           fi
            CFLAGS="$saved_CFLAGS"
            CXXFLAGS="$saved_CXXFLAGS"
        esac