__diag_ignore_all(), GCC < 8, extra warnings, and -Werror

From: Jani Nikula
Date: Wed Jul 05 2023 - 05:54:54 EST



For a long time now, i915 has enabled a bunch of W=1 style warnings
locally, and we try hard to keep i915 warning free.

One of the warnings is -Woverride-init from -Wextra. We need to bypass
that in a few cases, and used to do this for the relevant files:

CFLAGS_file.o = $(call cc-disable-warning, override-init)

Recently, we switched from the above to a more localized version in each
file.c:

__diag_push();
__diag_ignore_all("-Woverride-init", "Allow overriding inherited members");
...
__diag_pop();

We now got a report that this fails the build with CONFIG_WERROR=y or
W=e when using GCC version < 8. Indeed, __diag_ignore_all() requires GCC
version 8 or later.

Should we now revert back to disabling -Woverride-init on a file
granularity? Should we consider breaking the build for CONFIG_WERROR=y
or W=e on older compilers a regression?

I'll note that with the current usage of __diag_ignore_all() elsewhere
in kernel, CONFIG_WERROR=y or W=e with W=1 will never pass on older
compilers. But then again, it has never passed on any compiler, so it
can't be a regression.


BR,
Jani.


--
Jani Nikula, Intel Open Source Graphics Center