]> git.ipfire.org Git - thirdparty/gcc.git/commit
c: Fix -std=gnu23 -Wtraditional for () in function definitions
authorJoseph Myers <josmyers@redhat.com>
Sat, 19 Oct 2024 00:20:15 +0000 (00:20 +0000)
committerJoseph Myers <josmyers@redhat.com>
Sat, 19 Oct 2024 00:21:42 +0000 (00:21 +0000)
commitd277ded292d7e9eeaa0b8bce6782c4cd6b32d2c0
tree32d3beac860279637a02a77e6fecf4744a054879
parentde14559ef53b3a0e8c544bdc65f5983a184767b1
c: Fix -std=gnu23 -Wtraditional for () in function definitions

We don't yet have clear agreement on removing -Wtraditional (although
it seems there is little to no use for most of the warnings therein),
so fix the bug in its interaction with -std=gnu23 to continue progress
on making -std=gnu23 the default while -Wtraditional remains under
discussion.

The warning for ISO C function definitions with -Wtraditional properly
covers (void), but also wrongly warned for () in C23 mode as that has
the same semantics as (void) in that case.  Keep track in c_arg_info
of when () was converted to (void) for C23 so that -Wtraditional can
avoid warning in that case (with an appropriate comment on the
definition of the new field to make clear it can be removed along with
-Wtraditional).

Bootstrapped with no regressions for x86_64-pc-linux-gnu.

gcc/c/
* c-tree.h (c_arg_info): Add c23_empty_parens.
* c-decl.cc (grokparms): Set c23_empty_parens.
(build_arg_info): Clear c23_empty_parens.
(store_parm_decls_newstyle): Do not give -Wtraditional warning for
ISO C function definition if c23_empty_parens.

gcc/testsuite/
* gcc.dg/wtr-gnu17-1.c, gcc.dg/wtr-gnu23-1.c: New tests.
gcc/c/c-decl.cc
gcc/c/c-tree.h
gcc/testsuite/gcc.dg/wtr-gnu17-1.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/wtr-gnu23-1.c [new file with mode: 0644]