diff options
author | Joseph Myers <joseph@codesourcery.com> | 2022-09-01 19:10:59 +0000 |
---|---|---|
committer | Joseph Myers <joseph@codesourcery.com> | 2022-09-01 19:10:59 +0000 |
commit | 0a4b219d39c74aec7ebf87ac3be38d8f93efd634 (patch) | |
tree | 1d373c6356bce1bebd7d528f04dd1e1dfb9db9e4 /gcc/c | |
parent | d2694766dcfff0278fa93d581340a10b150c0f44 (diff) | |
download | gcc-0a4b219d39c74aec7ebf87ac3be38d8f93efd634.zip gcc-0a4b219d39c74aec7ebf87ac3be38d8f93efd634.tar.gz gcc-0a4b219d39c74aec7ebf87ac3be38d8f93efd634.tar.bz2 |
c: C2x removal of unprototyped functions
C2x has completely removed unprototyped functions, so that () now
means the same as (void) in both function declarations and
definitions, where previously that change had been made for
definitions only. Implement this accordingly.
This is a change where GNU/Linux distribution builders might wish to
try builds with a -std=gnu2x default to start early on getting old
code fixed that still has () declarations for functions taking
arguments, in advance of GCC moving to -std=gnu2x as default maybe in
GCC 14 or 15; I don't know how much such code is likely to be in
current use.
Bootstrapped with no regressions for x86_64-pc-linux-gnu.
gcc/c/
* c-decl.cc (grokparms): Handle () in a function declaration the
same as (void) for C2X.
gcc/testsuite/
* gcc.dg/c11-unproto-3.c, gcc.dg/c2x-unproto-3.c,
gcc.dg/c2x-unproto-4.c: New tests.
* gcc.dg/c2x-old-style-definition-6.c, gcc.dg/c2x-unproto-1.c,
gcc.dg/c2x-unproto-2.c: Update for removal of unprototyped
functions.
Diffstat (limited to 'gcc/c')
-rw-r--r-- | gcc/c/c-decl.cc | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/gcc/c/c-decl.cc b/gcc/c/c-decl.cc index 804314d..34f8fed 100644 --- a/gcc/c/c-decl.cc +++ b/gcc/c/c-decl.cc @@ -7868,7 +7868,7 @@ grokparms (struct c_arg_info *arg_info, bool funcdef_flag) error ("%<[*]%> not allowed in other than function prototype scope"); } - if (arg_types == NULL_TREE && !funcdef_flag + if (arg_types == NULL_TREE && !funcdef_flag && !flag_isoc2x && !in_system_header_at (input_location)) warning (OPT_Wstrict_prototypes, "function declaration isn%'t a prototype"); @@ -7896,9 +7896,8 @@ grokparms (struct c_arg_info *arg_info, bool funcdef_flag) tree parm, type, typelt; unsigned int parmno; - /* In C2X, convert () in a function definition to (void). */ + /* In C2X, convert () to (void). */ if (flag_isoc2x - && funcdef_flag && !arg_types && !arg_info->parms) arg_types = arg_info->types = void_list_node; |