]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
gdbsupport: add some -Wunused-* warning flags
authorSimon Marchi <simon.marchi@polymtl.ca>
Sat, 15 Mar 2025 22:13:41 +0000 (18:13 -0400)
committerSimon Marchi <simon.marchi@efficios.com>
Mon, 17 Mar 2025 20:14:08 +0000 (16:14 -0400)
Add a few -Wunused-* diagnostic flags that look useful.  Some are known
to gcc, some to clang, some to both.  Fix the fallouts.

-Wunused-const-variable=1 is understood by gcc, but not clang.
-Wunused-const-variable would be undertsood by both, but for gcc at
least it would flag the unused const variables in headers.  This doesn't
make sense to me, because as soon as one source file includes a header
but doesn't use a const variable defined in that header, it's an error.
With `=1`, gcc only warns about unused const variable in the main source
file.  It's not a big deal that clang doesn't understand it though: any
instance of that problem will be flagged by any gcc build.

Change-Id: Ie20d99524b3054693f1ac5b53115bb46c89a5156
Approved-By: Tom Tromey <tom@tromey.com>
13 files changed:
gdb/configure
gdb/dwarf2/cooked-index.c
gdb/dwarf2/cooked-index.h
gdb/dwarf2/index-write.c
gdb/dwarf2/read.c
gdb/dwarf2/read.h
gdb/elfread.c
gdb/mi/mi-out.c
gdb/mi/mi-out.h
gdb/symfile-debug.c
gdbserver/configure
gdbsupport/configure
gdbsupport/warning.m4

index f4f026297f8b7a4f3c814f19d68899606e4454b6..3080413fdc95c287be91ccc13121d5e29ac5acde 100755 (executable)
@@ -31295,7 +31295,13 @@ build_warnings=" \
 -Wsuggest-override \
 -Wunused-but-set-parameter \
 -Wunused-but-set-variable \
+-Wunused-const-variable=1 \
 -Wunused-function \
+-Wunused-label \
+-Wunused-lambda-capture \
+-Wunused-local-typedefs \
+-Wunused-member-function \
+-Wunused-private-field \
 -Wunused-value \
 -Wunused-variable \
 -Wvla \
index 13f0540f2a660b304be4c62dbd158963e445bc58..9626b2c16c0c95722e9f053b0e2e4196e131b463 100644 (file)
@@ -714,8 +714,7 @@ cooked_index_worker::write_to_cache (const cooked_index *idx,
 
 cooked_index::cooked_index (dwarf2_per_objfile *per_objfile,
                            cooked_index_worker_up &&worker)
-  : m_state (std::move (worker)),
-    m_per_bfd (per_objfile->per_bfd)
+  : m_state (std::move (worker))
 {
   /* ACTIVE_VECTORS is not locked, and this assert ensures that this
      will be caught if ever moved to the background.  */
index 02f4512213a6ce1eb52f336af63d4197fb6b666e..be67a83150dfb7b80f647cbe646d8928439b96b3 100644 (file)
@@ -651,8 +651,6 @@ private:
      that the state is CACHE_DONE -- it's important to note that only
      the main thread may change the value of this pointer.  */
   cooked_index_worker_up m_state;
-
-  dwarf2_per_bfd *m_per_bfd;
 };
 
 /* An implementation of quick_symbol_functions for the cooked DWARF
index 8fb59318538ef7a9971d2469435bca9206c1c0d6..da1f6cd1e0869620a99959639718a554882bab2c 100644 (file)
@@ -887,8 +887,7 @@ private:
 
     /* Object constructor to be called for current DWARF2_PER_BFD.  */
     debug_str_lookup (dwarf2_per_bfd *per_bfd)
-      : m_abfd (per_bfd->obfd),
-       m_per_bfd (per_bfd)
+      : m_per_bfd (per_bfd)
     {
     }
 
@@ -922,7 +921,6 @@ private:
 
   private:
     gdb::unordered_map<c_str_view, size_t, c_str_view_hasher> m_str_table;
-    bfd *const m_abfd;
     dwarf2_per_bfd *m_per_bfd;
 
     /* Data to add at the end of .debug_str for new needed symbol names.  */
index 85e4d59a9ab38a9c47d525df65b29658fe78b217..fd178e90a86125e22cd52223ee4338c5d021c2af 100644 (file)
@@ -3050,7 +3050,6 @@ cutu_reader::cutu_reader (dwarf2_per_cu *this_cu,
                          bool skip_partial,
                          enum language pretend_language,
                          const abbrev_table_cache *cache)
-  : m_this_cu (this_cu)
 {
   struct objfile *objfile = per_objfile->objfile;
   struct dwarf2_section_info *section = this_cu->section;
@@ -3279,7 +3278,6 @@ cutu_reader::cutu_reader (dwarf2_per_cu *this_cu,
                          enum language pretend_language,
                          struct dwarf2_cu *parent_cu,
                          struct dwo_file *dwo_file)
-  : m_this_cu (this_cu)
 {
   struct objfile *objfile = per_objfile->objfile;
   struct dwarf2_section_info *section = this_cu->section;
@@ -16192,9 +16190,6 @@ private:
 
   /* Additional bits of state we need to track.  */
 
-  /* The last file that we called dwarf2_start_subfile for.
-     This is only used for TLLs.  */
-  unsigned int m_last_file = 0;
   /* The last file a line number was recorded for.  */
   struct subfile *m_last_subfile = NULL;
 
index ced8154058467222725539e794c1ccff29f5e025..d498eeb00e06f19610f251ae5aa498087ec8414c 100644 (file)
@@ -1037,7 +1037,6 @@ private:
   struct die_info *m_top_level_die = nullptr;
   bool m_dummy_p = false;
 
-  dwarf2_per_cu *m_this_cu;
   dwarf2_cu_up m_new_cu;
 
   /* The ordinary abbreviation table.  */
index e81233c6be893cb5681c5aa74841b1f877a381a7..5be31183433b50cff84a77fbf5c9b5666f24918a 100644 (file)
@@ -592,7 +592,7 @@ elf_rel_plt_read (minimal_symbol_reader &reader,
   std::string string_buffer;
 
   /* Does ADDRESS reside in SECTION of OBFD?  */
-  auto within_section = [obfd] (asection *section, CORE_ADDR address)
+  auto within_section = [] (asection *section, CORE_ADDR address)
     {
       if (section == NULL)
        return false;
index 9ad26e76a30f505de7ce0abf1c9368654b950c7a..a704535f22ff539dd5c58978f986e60272a9500a 100644 (file)
@@ -323,7 +323,6 @@ mi_ui_out::version ()
 mi_ui_out::mi_ui_out (int mi_version)
 : ui_out (make_flags (mi_version)),
   m_suppress_field_separator (false),
-  m_suppress_output (false),
   m_mi_version (mi_version)
 {
   string_file *stream = new string_file ();
index 0112d5a7dd4589eb00a2e1922259e63b0ed4803b..c6aad00c2330f5fa924235109d5e475c14fb3371 100644 (file)
@@ -139,7 +139,6 @@ private:
   }
 
   bool m_suppress_field_separator;
-  bool m_suppress_output;
   int m_mi_version;
   std::vector<ui_file *> m_streams;
 };
index dda3efe9db35fa9bded93edf77ded7a0250a96b2..937839856b27fa7e38d472b9dccd3c125d0af878 100644 (file)
@@ -789,24 +789,6 @@ debug_sym_relocate (struct objfile *objfile, asection *sectp, bfd_byte *buf)
   return retval;
 }
 
-/* Template of debugging version of struct sym_fns.
-   A copy is made, with sym_flavour updated, and a pointer to the real table
-   installed in real_sf, and then a pointer to the copy is installed in the
-   objfile.  */
-
-static const struct sym_fns debug_sym_fns =
-{
-  debug_sym_new_init,
-  debug_sym_init,
-  debug_sym_read,
-  debug_sym_finish,
-  debug_sym_offsets,
-  debug_sym_segments,
-  debug_sym_read_linetable,
-  debug_sym_relocate,
-  &debug_sym_probe_fns,
-};
-\f
 /* Install the debugging versions of the symfile functions for OBJFILE.
    Do not call this if the debug versions are already installed.  */
 
index 0deb14656f518548f82430eb4d785509201d8038..b45b55ffde7a23716fd9f788bc7eeecc183e96d6 100755 (executable)
@@ -13692,7 +13692,13 @@ build_warnings=" \
 -Wsuggest-override \
 -Wunused-but-set-parameter \
 -Wunused-but-set-variable \
+-Wunused-const-variable=1 \
 -Wunused-function \
+-Wunused-label \
+-Wunused-lambda-capture \
+-Wunused-local-typedefs \
+-Wunused-member-function \
+-Wunused-private-field \
 -Wunused-value \
 -Wunused-variable \
 -Wvla \
index 63619d7b3a7a357476ab5b01b1e97142d28c011b..bcfae3460e55382adca3ee15a5141e447c51880d 100755 (executable)
@@ -14254,7 +14254,13 @@ build_warnings=" \
 -Wsuggest-override \
 -Wunused-but-set-parameter \
 -Wunused-but-set-variable \
+-Wunused-const-variable=1 \
 -Wunused-function \
+-Wunused-label \
+-Wunused-lambda-capture \
+-Wunused-local-typedefs \
+-Wunused-member-function \
+-Wunused-private-field \
 -Wunused-value \
 -Wunused-variable \
 -Wvla \
index b7c2dc5c4bc36a93b1e9f9e166dc929a1343115b..04b58f186f171e92a28470e0b39917f49fa2c4da 100644 (file)
@@ -57,7 +57,13 @@ build_warnings=" \
 -Wsuggest-override \
 -Wunused-but-set-parameter \
 -Wunused-but-set-variable \
+-Wunused-const-variable=1 \
 -Wunused-function \
+-Wunused-label \
+-Wunused-lambda-capture \
+-Wunused-local-typedefs \
+-Wunused-member-function \
+-Wunused-private-field \
 -Wunused-value \
 -Wunused-variable \
 -Wvla \