[PATCH 2/2] Ignore missing braces error for GCC 4.9 or older
Sam James
sam@gentoo.org
Sun Dec 15 19:06:38 GMT 2024
"H.J. Lu" <hjl.tools@gmail.com> writes:
> On Sun, Dec 15, 2024 at 9:00 PM Florian Weimer <fw@deneb.enyo.de> wrote:
>>
>> * H. J. Lu:
>>
>> > Since not all targets need braces, ignore missing braces error for GCC
>> > 4.9 or older:
>> >
>> > tst-system.c: In function ‘sleep_and_check_sigchld’:
>> > tst-system.c:83:3: error: missing braces around initializer [-Werror=missing-braces]
>> > sigset_t blocked = {0};
>> > ^
>> > tst-system.c:83:3: error: (near initialization for ‘blocked.__val’) [-Werror=missing-braces]
>> > cc1: all warnings being treated as errors
>> >
>> > Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
>> > ---
>> > posix/tst-spawn7.c | 15 +++++++++++++++
>> > rt/tst-timer-sigmask.c | 15 +++++++++++++++
>> > stdlib/tst-system.c | 8 ++++++++
>> > sysdeps/pthread/tst-cancel28.c | 15 +++++++++++++++
>> > 4 files changed, 53 insertions(+)
>> >
>> > diff --git a/posix/tst-spawn7.c b/posix/tst-spawn7.c
>> > index e4adc6cbf0..14b755081c 100644
>> > --- a/posix/tst-spawn7.c
>> > +++ b/posix/tst-spawn7.c
>> > @@ -27,6 +27,7 @@
>> > #include <sys/wait.h>
>> > #include <unistd.h>
>> > #include <tst-spawn.h>
>> > +#include <libc-diag.h>
>> >
>> > /* Nonzero if the program gets called via `exec'. */
>> > #define CMDLINE_OPTIONS \
>> > @@ -114,7 +115,14 @@ do_test_signals (void)
>> > {
>> > /* Same as before, but set SIGUSR1 and SIGUSR2 to a handler different than
>> > SIG_IGN or SIG_DFL. */
>> > +#if !__GNUC_PREREQ (5, 0)
>> > + DIAG_PUSH_NEEDS_COMMENT;
>> > + DIAG_IGNORE_NEEDS_COMMENT (4.9, "-Wmissing-braces");
>> > +#endif
>> > struct sigaction sa = { 0 };
>> > +#if !__GNUC_PREREQ (5, 0)
>> > + DIAG_POP_NEEDS_COMMENT;
>> > +#endif
>>
>> Why not write “= { }” instead? That GCC extension is quite old?
>
> I will see what I can do. I am working on Clang testing. It is a
> big effort. I fixed some tests. But there are still 700+ tests that
> won't compile with Clang 19. Some fixes aren't too hard. But
> many aren't easy.
I will help with it too. Thank you for doing it.
>
>> If we want to get the test sources to compile without any GCC
>> extensions, that's going to be a much larger effort.
More information about the Libc-alpha
mailing list