[RFA,6/6] Add -Wunused-but-set-* to build

Message ID 1465248812-23902-7-git-send-email-tom@tromey.com
State New, archived
Headers

Commit Message

Tom Tromey June 6, 2016, 9:33 p.m. UTC
  This adds -Wunused-but-set-variable and -Wunused-but-set-parameter to
configure.

2016-06-06  Tom Tromey  <tom@tromey.com>

	* configure: Rebuild.
	* warning.m4 (AM_GDB_WARNINGS) <build_warnings>: Add
	-Wunused-but-set-parameter, -Wunused-but-set-variable.

2016-06-06  Tom Tromey  <tom@tromey.com>

	* configure: Rebuild.
---
 gdb/ChangeLog           | 6 ++++++
 gdb/configure           | 2 +-
 gdb/gdbserver/ChangeLog | 4 ++++
 gdb/gdbserver/configure | 2 +-
 gdb/warning.m4          | 2 +-
 5 files changed, 13 insertions(+), 3 deletions(-)
  

Comments

Trevor Saunders June 8, 2016, 2:37 a.m. UTC | #1
On Mon, Jun 06, 2016 at 03:33:32PM -0600, Tom Tromey wrote:
> This adds -Wunused-but-set-variable and -Wunused-but-set-parameter to
> configure.

 great, I started on that a little while ago but didn't get to pushing
 these bits upstream.

> +++ b/gdb/warning.m4
> @@ -39,7 +39,7 @@ fi
>  build_warnings="-Wall -Wpointer-arith \
>  -Wno-unused -Wunused-value -Wunused-function \
>  -Wno-switch -Wno-char-subscripts \
> --Wempty-body"
> +-Wempty-body -Wunused-but-set-parameter -Wunused-but-set-variable"

isn't everything in -Wunused enabled now? can we just delete -Wno-unused
and use -Wall to get us -Wunused?

Trev
  
Tom Tromey June 8, 2016, 2:46 a.m. UTC | #2
>>>>> "Trevor" == Trevor Saunders <tbsaunde@tbsaunde.org> writes:

Trevor> isn't everything in -Wunused enabled now? can we just delete
Trevor> -Wno-unused and use -Wall to get us -Wunused?

I didn't think of that -- thanks.  From the gcc docs I see
-Wunused-label, -Wunused-local-typedefs, and -Wunused-parameter.  That
final one seems difficult for gdb given the many functions that are
called via function pointers but which do not use all their arguments.

Once the switch to C++ is complete, such parameters could be nameless.
To me that seems better than sticking ATTRIBUTE_UNUSED in many places.

Tom
  
Trevor Saunders June 8, 2016, 3:24 a.m. UTC | #3
On Tue, Jun 07, 2016 at 08:46:35PM -0600, Tom Tromey wrote:
> >>>>> "Trevor" == Trevor Saunders <tbsaunde@tbsaunde.org> writes:
> 
> Trevor> isn't everything in -Wunused enabled now? can we just delete
> Trevor> -Wno-unused and use -Wall to get us -Wunused?
> 
> I didn't think of that -- thanks.  From the gcc docs I see
> -Wunused-label, -Wunused-local-typedefs, and -Wunused-parameter.  That
> final one seems difficult for gdb given the many functions that are
> called via function pointers but which do not use all their arguments.

the docs for -Wunused-parameter are... tricky, but I believe what they
say is -Wall -Wunused does not enable -Wunused-parameter, to enable
-Wunused-parameter you either need to pass it explicitly, or pass
-Wextra -Wunused.

> Once the switch to C++ is complete, such parameters could be nameless.
> To me that seems better than sticking ATTRIBUTE_UNUSED in many places.

I'd agree, and at that point it might make sense to enable
-Wunused-parameter.

Trev

> 
> Tom
  
Tom Tromey June 8, 2016, 3:43 a.m. UTC | #4
Trevor> the docs for -Wunused-parameter are... tricky, but I believe what they
Trevor> say is -Wall -Wunused does not enable -Wunused-parameter, to enable
Trevor> -Wunused-parameter you either need to pass it explicitly, or pass
Trevor> -Wextra -Wunused.

Yes, I see.  I think I misread them.  They say:

    '-Wunused'
         All the above '-Wunused' options combined.

         In order to get a warning about an unused function parameter, you
         must either specify '-Wextra -Wunused' (note that '-Wall' implies
         '-Wunused'), or separately specify '-Wunused-parameter'.

The first line implies that -Wunused-parameter is part of this, but then
subsequent text says not.

I'll give it a try and see what happens.

Tom
  
Tom Tromey June 8, 2016, 4:15 a.m. UTC | #5
Tom> I'll give it a try and see what happens.

It turns out that -Wunused-variable causes a number of errors (104 in my
build).  So, I think that while this change would be worthwhile, it's a
bit too much for me at present.

Tom
  
Trevor Saunders June 8, 2016, 4:33 a.m. UTC | #6
On Tue, Jun 07, 2016 at 10:15:59PM -0600, Tom Tromey wrote:
> Tom> I'll give it a try and see what happens.
> 
> It turns out that -Wunused-variable causes a number of errors (104 in my
> build).  So, I think that while this change would be worthwhile, it's a
> bit too much for me at present.

Sure, I'll probably get to it in a couple weeks if you don't get there
first (I eventually want to merge bfd/warnings.m4 and gdb/warnings.m4)

Trev

> 
> Tom
  

Patch

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index eec280d..9c0ff17 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,11 @@ 
 2016-06-06  Tom Tromey  <tom@tromey.com>
 
+	* configure: Rebuild.
+	* warning.m4 (AM_GDB_WARNINGS) <build_warnings>: Add
+	-Wunused-but-set-parameter, -Wunused-but-set-variable.
+
+2016-06-06  Tom Tromey  <tom@tromey.com>
+
 	* mips-tdep.c (micromips_scan_prologue): Remove "frame_addr".
 	(mips_o32_push_dummy_call): Remove "stack_used_p".
 	* aarch64-tdep.c (aarch64_record_data_proc_imm): Remove
diff --git a/gdb/configure b/gdb/configure
index 60ea884..957d0e4 100755
--- a/gdb/configure
+++ b/gdb/configure
@@ -14242,7 +14242,7 @@  fi
 build_warnings="-Wall -Wpointer-arith \
 -Wno-unused -Wunused-value -Wunused-function \
 -Wno-switch -Wno-char-subscripts \
--Wempty-body"
+-Wempty-body -Wunused-but-set-parameter -Wunused-but-set-variable"
 
 # Now add in C and C++ specific options, depending on mode.
 if test "$enable_build_with_cxx" = "yes"; then
diff --git a/gdb/gdbserver/ChangeLog b/gdb/gdbserver/ChangeLog
index 079507a..8bef0bd 100644
--- a/gdb/gdbserver/ChangeLog
+++ b/gdb/gdbserver/ChangeLog
@@ -1,3 +1,7 @@ 
+2016-06-06  Tom Tromey  <tom@tromey.com>
+
+	* configure: Rebuild.
+
 2016-06-02  Jon Turney  <jon.turney@dronecode.org.uk>
 
 	* win32-low.c (win32_create_inferior): Add pointer casts for C++.
diff --git a/gdb/gdbserver/configure b/gdb/gdbserver/configure
index 746218e..2926deb 100755
--- a/gdb/gdbserver/configure
+++ b/gdb/gdbserver/configure
@@ -6291,7 +6291,7 @@  fi
 build_warnings="-Wall -Wpointer-arith \
 -Wno-unused -Wunused-value -Wunused-function \
 -Wno-switch -Wno-char-subscripts \
--Wempty-body"
+-Wempty-body -Wunused-but-set-parameter -Wunused-but-set-variable"
 
 # Now add in C and C++ specific options, depending on mode.
 if test "$enable_build_with_cxx" = "yes"; then
diff --git a/gdb/warning.m4 b/gdb/warning.m4
index 55f1eb3..8d7ce68 100644
--- a/gdb/warning.m4
+++ b/gdb/warning.m4
@@ -39,7 +39,7 @@  fi
 build_warnings="-Wall -Wpointer-arith \
 -Wno-unused -Wunused-value -Wunused-function \
 -Wno-switch -Wno-char-subscripts \
--Wempty-body"
+-Wempty-body -Wunused-but-set-parameter -Wunused-but-set-variable"
 
 # Now add in C and C++ specific options, depending on mode.
 if test "$enable_build_with_cxx" = "yes"; then