On Wed, Jun 25 2025, Martin Jambor wrote:
> 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.
>

[...]

> 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.
>

I am about to push the following changes to the contrib file.

Thanks,

Martin

----------------------------------------------------------------------
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 in ipa-strub.cc.

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. Ignore -Wc++11-narrowing warning reported in omp-builtins.def when
   it is included from JIT.  The code probably has a bigger issue
   described in PR 120960.

9. Since the patch number 14 in the original series did not get
   approved, I assume that private member field m_wanted_type of class
   element_expected_type_with_indirection in c-family/c-format.cc will
   get a use sooner or later, so I ignore a warning about it being
   unused.

10. 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.

11. 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.

12. 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]

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

14. In analyzer/sm.cc there are several "no-op" methods which have
    named but unused parameters.  It seems this is deliberate and so I
    have filtered the -Wunused-parameter warning for this file.

I have also re-arranged the entries in a way which hopefully makes
somewhat more sense.

Thanks,

Martin

contrib/ChangeLog:

2025-07-07  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 -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, in
        analyzer/ana-state-to-diagnostic-state.h and c-family/c-format.cc, all
        Warnings in avr-mmcu.texi, install.texi and libgccjit.texi and all
        -Wc23-extensions warnings in libiberty/sha1.c. Ignore
        -Wunused-parameter in analyzer/sm.cc.  Reorder entries.
---
 contrib/filter-clang-warnings.py | 35 +++++++++++++++++++++++++-------
 1 file changed, 28 insertions(+), 7 deletions(-)

diff --git a/contrib/filter-clang-warnings.py b/contrib/filter-clang-warnings.py
index 2ea7c710163..b1b881eec3e 100755
--- a/contrib/filter-clang-warnings.py
+++ b/contrib/filter-clang-warnings.py
@@ -41,22 +41,43 @@ 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'],
+            'fold-const-call.cc': ['-Wreturn-type'],
+            'gimple-match': ['-Wunused-', '-Wtautological-compare'],
+            'generic-match': ['-Wunused-', '-Wtautological-compare'],
+            'genautomata.cc': ['-Wstring-plus-int'],
+            # 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'],
+            'omp-builtins.def': ['-Wc++11-narrowing'],
+            'wide-int.h': ['-Wnontrivial-memcall'],
             'i386.md': ['-Wparentheses-equality', '-Wtautological-compare',
                         '-Wtautological-overlap-compare'],
             'sse.md': ['-Wparentheses-equality', '-Wtautological-compare',
                        '-Wconstant-logical-operand'],
             'mmx.md': ['-Wtautological-compare'],
-            'genautomata.cc': ['-Wstring-plus-int'],
-            'fold-const-call.cc': ['-Wreturn-type'],
-            'gfortran.texi': [''],
-            'libtool': [''],
             'lex.cc': ['-Wc++20-attribute-extensions'],
+            # Perhaps remove once PR 120960 is resolved:
+            'analyzer/ana-state-to-diagnostic-state.h': 
['-Wunused-private-field'],
+            'analyzer/sm.cc': ['-Wunused-parameter'],
+            'c-family/c-format.cc': ['-Wunused-private-field'],
+            'm2/gm2-compiler-boot': ['-Wunused-'],
+            # Rust peopel promised to clean these warnings too
+            'rust/': ['-Wunused-private-field'],
+                 'libiberty/sha1.c': ['-Wc23-extensions'],
+            'avr-mmcu.texi': [''],
+            'gfortran.texi': [''],
+            'install.texi': [''],
+            'libgccjit.texi': [''],
+            'libtool': ['']
     }
 
     for name, ignore in ignores.items():
-- 
2.49.0

Reply via email to