This is the mail archive of the gdb-cvs@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[binutils-gdb] Add -Wunused-variable to warnings.m4


https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=a0de763e32b381369896fef63d221376f29a9113

commit a0de763e32b381369896fef63d221376f29a9113
Author: Tom Tromey <tom@tromey.com>
Date:   Sun Jul 8 21:05:41 2018 -0600

    Add -Wunused-variable to warnings.m4
    
    This adds -Wunused-variable to the build.  This required a special
    check in configure in order to work around a bug in GCC 4.9.  Simon
    ound the correct test to use, so I've added him to the ChangeLog.
    
    gdb/ChangeLog
    2018-07-22  Simon Marchi  <simon.marchi@polymtl.ca>
    	    Tom Tromey  <tom@tromey.com>
    
    	* warning.m4 (AM_GDB_WARNINGS): Add -Wunused-variable and special
    	test for it.
    	* configure: Rebuild.
    
    gdb/gdbserver/ChangeLog
    2018-07-22  Tom Tromey  <tom@tromey.com>
    
    	* configure: Rebuild.

Diff:
---
 gdb/ChangeLog           |  7 +++++++
 gdb/configure           | 28 ++++++++++++++++++++++++++--
 gdb/gdbserver/ChangeLog |  4 ++++
 gdb/gdbserver/configure | 28 ++++++++++++++++++++++++++--
 gdb/warning.m4          | 17 +++++++++++++++--
 5 files changed, 78 insertions(+), 6 deletions(-)

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 972184d..388b923 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,10 @@
+2018-07-22  Simon Marchi  <simon.marchi@polymtl.ca>
+	    Tom Tromey  <tom@tromey.com>
+
+	* warning.m4 (AM_GDB_WARNINGS): Add -Wunused-variable and special
+	test for it.
+	* configure: Rebuild.
+
 2018-07-22  Tom Tromey  <tom@tromey.com>
 
 	* regformats/regdat.sh: Define xmltarget_${name} inside
diff --git a/gdb/configure b/gdb/configure
index 3f0a220..3ee88e4 100755
--- a/gdb/configure
+++ b/gdb/configure
@@ -15439,7 +15439,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 \
@@ -15528,7 +15528,30 @@ $as_echo_n "checking compiler warning flags... " >&6; }
 	    CFLAGS="$CFLAGS -Werror $wtest"
 	    saved_CXXFLAGS="$CXXFLAGS"
 	    CXXFLAGS="$CXXFLAGS -Werror $wtest"
-	    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+	    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.
+	      cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+struct scoped_restore_base {};
+                 struct scoped_restore_tmpl : public scoped_restore_base {
+		   ~scoped_restore_tmpl() {}
+		 };
+int
+main ()
+{
+const scoped_restore_base &b = scoped_restore_tmpl();
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_cxx_try_compile "$LINENO"; then :
+  WARN_CFLAGS="${WARN_CFLAGS} $w"
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+	    else
+	      cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 
 int
@@ -15543,6 +15566,7 @@ if ac_fn_cxx_try_compile "$LINENO"; then :
   WARN_CFLAGS="${WARN_CFLAGS} $w"
 fi
 rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+	    fi
 	    CFLAGS="$saved_CFLAGS"
 	    CXXFLAGS="$saved_CXXFLAGS"
 	esac
diff --git a/gdb/gdbserver/ChangeLog b/gdb/gdbserver/ChangeLog
index eccf556..23369e4 100644
--- a/gdb/gdbserver/ChangeLog
+++ b/gdb/gdbserver/ChangeLog
@@ -1,5 +1,9 @@
 2018-07-22  Tom Tromey  <tom@tromey.com>
 
+	* configure: Rebuild.
+
+2018-07-22  Tom Tromey  <tom@tromey.com>
+
 	* win32-low.c (win32_create_inferior): Remove unused variables.
 	* gdbreplay.c (remote_open): Remove unused variable.
 	* remote-utils.c (remote_prepare): Remove unused variable.
diff --git a/gdb/gdbserver/configure b/gdb/gdbserver/configure
index 6064a1e..043bc21 100755
--- a/gdb/gdbserver/configure
+++ b/gdb/gdbserver/configure
@@ -7237,7 +7237,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 \
@@ -7326,7 +7326,30 @@ $as_echo_n "checking compiler warning flags... " >&6; }
 	    CFLAGS="$CFLAGS -Werror $wtest"
 	    saved_CXXFLAGS="$CXXFLAGS"
 	    CXXFLAGS="$CXXFLAGS -Werror $wtest"
-	    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+	    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.
+	      cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+struct scoped_restore_base {};
+                 struct scoped_restore_tmpl : public scoped_restore_base {
+		   ~scoped_restore_tmpl() {}
+		 };
+int
+main ()
+{
+const scoped_restore_base &b = scoped_restore_tmpl();
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_cxx_try_compile "$LINENO"; then :
+  WARN_CFLAGS="${WARN_CFLAGS} $w"
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+	    else
+	      cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 
 int
@@ -7341,6 +7364,7 @@ if ac_fn_cxx_try_compile "$LINENO"; then :
   WARN_CFLAGS="${WARN_CFLAGS} $w"
 fi
 rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+	    fi
 	    CFLAGS="$saved_CFLAGS"
 	    CXXFLAGS="$saved_CXXFLAGS"
 	esac
diff --git a/gdb/warning.m4 b/gdb/warning.m4
index 632cc21..00e7cd6 100644
--- a/gdb/warning.m4
+++ b/gdb/warning.m4
@@ -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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]