Skip to content
Snippets Groups Projects
Commit d277ded2 authored by Joseph Myers's avatar Joseph Myers
Browse files

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.
parent de14559e
No related branches found
No related tags found
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment