Hi,

in contrib we have a script filter-clang-warnings.py which supposedly
filters out uninteresting warnings emitted by clang when it compiles
GCC.  I'm not sure if anyone else uses it but our internal SUSE
testing infrastructure does.

Since Martin Liška left, I have mostly ignored the warnings and so
they have multiplied.  In an effort to improve the situation, I have
tried to fix those warnings which I think are worth it and would like
to adjust the filtering script so that we get to zero "interesting"
warnings again.

The changes are the following:

1. Ignore -Woverloaded-shift-op-parentheses warnings.  IIUC, those
   make some sense when << and >> are used for I/O but since that is
   not the case in GCC they are not really interesting.

2. Ignore -Wunused-function and -Wunneeded-internal-declaration.  I
   think it is OK to occasionally prepare APIs before they are used
   (and with our LTO we should be able to get rid of them).

3. Ignore -Wvla-cxx-extension and -Wunused-command-line-argument which
   just don't seem to be useful.

4. Ignore -Wunused-private-field warning in diagnostic-path-output.cc
   which can only be correct if quite a few functions are removed and
   looks like it is just not an oversight:

     gcc/diagnostic-path-output.cc:271:35: warning: private field 
'm_logical_loc_mgr' is not used [-Wunused-private-field]

5. Ignore a case in -Wunused-but-set-variable about named_args which
   is used in a piece of code behind an ifdef.

6. Adjust the gimple-match and generic-match filters to the fact that
   we now have multiple such files.

7. Ignore warnings about using memcpy to copy around wide_ints, like
   the one below.  I seem to remember wide-int has undergone fairly
   rigorous review and TBH I just hope I know what we are doing.

     gcc/wide-int.h:1198:11: warning: first argument in call to 'memcpy' is a 
pointer to non-trivially copyable type 'wide_int_storage' [-Wnontrivial-memcall]

8. I have decided to ignore warnings in m2/gm2-compiler-boot about
   unused stuff (all reported unused stuff are variables).  These
   sources are in the build directory so I assume they are somehow
   generated and so warnings about unused things are a bit expected
   and probably not too bad.

9. On the Zulip chat, I have informed Rust folks they have a bunch of
   -Wunused-private-field cases in the FE.  Until they sort it out I'm
   ignoring these.  I might add the missing explicit type-cast case
   here too if it takes time for the patch I'm posting in this series
   to reach master.

10. I ignore warning about use of offsetof in libiberty/sha1.c which is
    apparently only a "C23 extension:"

      libiberty/sha1.c:239:11: warning: defining a type within 'offsetof' is a 
C23 extension [-Wc23-extensions]
      libiberty/sha1.c:460:11: warning: defining a type within 'offsetof' is a 
C23 extension [-Wc23-extensions]

11. I have enlarged the list of .texi files where warnings somehow got
    reported.  Not sure why that happens.

12. I'm ignoring the -Wunused-const-variable case in value-relation.cc
    until Andrew commits the patch he has to remove it.

With these changes and my other patches, we reach zero interesting
warnings.

Since I don't think anyone else uses the script, I'm would like to
declare these changes "obvious" in the sense that they are obviously
useful for me and obviously nobody else will mind or even be affected.
I'm going to hold off for a week though, please let me know if I'm
stretching the obvious rule too much here.

Thanks,

Martin



contrib/ChangeLog:

2025-06-25  Martin Jambor  <mjam...@suse.cz>

        * filter-clang-warnings.py (skip_warning): Also ignore
        -Woverloaded-shift-op-parentheses, -Wunused-function,
        -Wunneeded-internal-declaration, -Wvla-cxx-extension', and
        -Wunused-command-line-argument everywhere and a warning about
        m_logical_loc_mgr in diagnostic-path-output.cc.  Adjust gimple-match
        and generic-match "filenames."  Ignore -Wunused-const-variable
        warnings in value-relation.cc, -Wnontrivial-memcall warnings in
        wide-int.h, all warnings about unused stuff in files under
        m2/gm2-compiler-boot, all -Wunused-private-field in rust FE, all
        Warnings in avr-mmcu.texi, install.texi and libgccjit.texi and all
        -Wc23-extensions warnings in libiberty/sha1.c.
---
 contrib/filter-clang-warnings.py | 24 +++++++++++++++++++++---
 1 file changed, 21 insertions(+), 3 deletions(-)

diff --git a/contrib/filter-clang-warnings.py b/contrib/filter-clang-warnings.py
index 2ea7c710163..f0f7885d26d 100755
--- a/contrib/filter-clang-warnings.py
+++ b/contrib/filter-clang-warnings.py
@@ -41,12 +41,22 @@ def skip_warning(filename, message):
                  '-Wignored-attributes', '-Wgnu-zero-variadic-macro-arguments',
                  '-Wformat-security', '-Wundefined-internal',
                  '-Wunknown-warning-option', '-Wc++20-extensions',
-                 '-Wbitwise-instead-of-logical', 'egrep is obsolescent'],
+                 '-Wbitwise-instead-of-logical', 'egrep is obsolescent',
+                 '-Woverloaded-shift-op-parentheses',
+                 '-Wunused-function', '-Wunneeded-internal-declaration',
+                 '-Wvla-cxx-extension', '-Wunused-command-line-argument'],
+
+            'diagnostic-path-output.cc': ['m_logical_loc_mgr'],
+
+# Perhaps revisit when ATTR_FNSPEC_DECONST_WATERMARK ifdef case is made default
+# or removed:
+            'ipa-strub.cc': ['-Wunused-but-set-variable'],
+
             'insn-modes.cc': ['-Wshift-count-overflow'],
             'insn-emit.cc': ['-Wtautological-compare'],
             'insn-attrtab.cc': ['-Wparentheses-equality'],
-            'gimple-match.cc': ['-Wunused-', '-Wtautological-compare'],
-            'generic-match.cc': ['-Wunused-', '-Wtautological-compare'],
+            'gimple-match': ['-Wunused-', '-Wtautological-compare'],
+            'generic-match': ['-Wunused-', '-Wtautological-compare'],
             'i386.md': ['-Wparentheses-equality', '-Wtautological-compare',
                         '-Wtautological-overlap-compare'],
             'sse.md': ['-Wparentheses-equality', '-Wtautological-compare',
@@ -54,9 +64,17 @@ def skip_warning(filename, message):
             'mmx.md': ['-Wtautological-compare'],
             'genautomata.cc': ['-Wstring-plus-int'],
             'fold-const-call.cc': ['-Wreturn-type'],
+            'value-relation.cc': ['-Wunused-const-variable'],
+            'wide-int.h': ['-Wnontrivial-memcall'],
+            'm2/gm2-compiler-boot': ['-Wunused-'],
+            'rust/': ['-Wunused-private-field'],
+            'avr-mmcu.texi': [''],
             'gfortran.texi': [''],
+            'install.texi': [''],
+            'libgccjit.texi': [''],
             'libtool': [''],
             'lex.cc': ['-Wc++20-attribute-extensions'],
+            'libiberty/sha1.c': ['-Wc23-extensions']
     }
 
     for name, ignore in ignores.items():
-- 
2.49.0

Reply via email to