@@ -8519,7 +8519,10 @@ grokparms (struct c_arg_info *arg_info, bool funcdef_flag)
&& !arg_types
&& !arg_info->parms
&& !arg_info->no_named_args_stdarg_p)
- arg_types = arg_info->types = void_list_node;
+ {
+ arg_types = arg_info->types = void_list_node;
+ arg_info->c23_empty_parens = 1;
+ }
/* If there is a parameter of incomplete type in a definition,
this is an error. In a declaration this is valid, and a
@@ -8589,6 +8592,7 @@ build_arg_info (void)
ret->pending_sizes = NULL;
ret->had_vla_unspec = 0;
ret->no_named_args_stdarg_p = 0;
+ ret->c23_empty_parens = 0;
return ret;
}
@@ -10923,7 +10927,8 @@ store_parm_decls_newstyle (tree fndecl, const struct c_arg_info *arg_info)
its parameter list). */
else if (!in_system_header_at (input_location)
&& !current_function_scope
- && arg_info->types != error_mark_node)
+ && arg_info->types != error_mark_node
+ && !arg_info->c23_empty_parens)
warning_at (DECL_SOURCE_LOCATION (fndecl), OPT_Wtraditional,
"traditional C rejects ISO C style function definitions");
@@ -525,6 +525,10 @@ struct c_arg_info {
BOOL_BITFIELD had_vla_unspec : 1;
/* True when the arguments are a (...) prototype. */
BOOL_BITFIELD no_named_args_stdarg_p : 1;
+ /* True when empty parentheses have been interpreted as (void) in C23 or
+ later. This is only for use by -Wtraditional and is no longer needed if
+ -Wtraditional is removed. */
+ BOOL_BITFIELD c23_empty_parens : 1;
};
/* A declarator. */
new file mode 100644
@@ -0,0 +1,9 @@
+/* Test -Wtraditional -std=gnu17 does not warn for empty parentheses in
+ function definition. */
+/* { dg-do compile } */
+/* { dg-options "-Wtraditional -std=gnu17" } */
+
+void
+f ()
+{
+}
new file mode 100644
@@ -0,0 +1,9 @@
+/* Test -Wtraditional -std=gnu23 does not warn for empty parentheses in
+ function definition. */
+/* { dg-do compile } */
+/* { dg-options "-Wtraditional -std=gnu23" } */
+
+void
+f ()
+{
+}