C++ ObjC++ Var(warn_multiple_inheritance) Warning
Warn on direct multiple inheritance.
+Wmultiple-parameter-fwd-decl-lists
+C ObjC Var(warn_multiple_parameter_fwd_decl_lists) Warning EnabledBy(Wextra)
+Warn for multiple lists of forward declarations of function parameters.
+
Wmultistatement-macros
C ObjC C++ ObjC++ Var(warn_multistatement_macros) Warning LangEnabledBy(C ObjC C++ ObjC++,Wall)
Warn about unsafe macros expanding to multiple statements used as a body of a clause such as if, else, while, switch, or for.
if these appears in a function definition. */
BOOL_BITFIELD had_vla_unspec : 1;
- /* True if we already complained about forward parameter decls
- in this scope. This prevents double warnings on
- foo (int a; int b; ...) */
- BOOL_BITFIELD warned_forward_parm_decls : 1;
+ /* True if we parsed a list of forward parameter decls in this scope. */
+ BOOL_BITFIELD had_forward_parm_decls : 1;
/* True if this is the outermost block scope of a function body.
This scope contains the parameters, the local variables declared
{
struct c_binding *b;
- if (pedantic && !current_scope->warned_forward_parm_decls)
- {
- pedwarn (input_location, OPT_Wpedantic,
- "ISO C forbids forward parameter declarations");
- current_scope->warned_forward_parm_decls = true;
- }
+ if (current_scope->had_forward_parm_decls)
+ warning_at (input_location, OPT_Wmultiple_parameter_fwd_decl_lists,
+ "more than one list of forward declarations of parameters");
+ if (pedantic && !current_scope->had_forward_parm_decls)
+ pedwarn (input_location, OPT_Wpedantic,
+ "ISO C forbids forward parameter declarations");
+
+ current_scope->had_forward_parm_decls = true;
for (b = current_scope->bindings; b; b = b->prev)
if (TREE_CODE (b->decl) == PARM_DECL)
@end smallexample
@cindex parameter forward declaration
-The @samp{int len} before the semicolon is a @dfn{parameter forward
-declaration}, and it serves the purpose of making the name @code{len}
-known when the declaration of @code{data} is parsed.
-
-You can write any number of such parameter forward declarations in the
-parameter list. They can be separated by commas or semicolons, but the
-last one must end with a semicolon, which is followed by the ``real''
-parameter declarations. Each forward declaration must match a ``real''
-declaration in parameter name and data type. ISO C99 does not support
-parameter forward declarations.
+The @samp{int len} before the semicolon
+is a @dfn{parameter forward declaration},
+and it serves the purpose of making the name @code{len} known
+when the declaration of @code{data} is parsed.
+
+Lists of parameter forward declarations are terminated by semicolons,
+and parameter forward declarations are separated within such lists by commas,
+just like in the regular list of parameter declarations.
+
+You can write any number of lists of parameter forward declaration,
+but using more than one is unnecessary.
+The last semicolon is followed by the list of parameter declarations.
+Each parameter forward declaration must match
+a parameter declaration in parameter name and data type.
+ISO C99 does not support parameter forward declarations.
@node Zero Length
@subsection Arrays of Length Zero
@gccoptlist{-Wbad-function-cast -Wdeprecated-non-prototype -Wfree-labels
-Wmissing-declarations -Wmissing-parameter-name -Wmissing-parameter-type
-Wdeclaration-missing-parameter-type -Wmissing-prototypes
--Wmissing-variable-declarations -Wnested-externs -Wold-style-declaration
+-Wmissing-variable-declarations
+-Wmultiple-parameter-fwd-decl-lists
+-Wnested-externs -Wold-style-declaration
-Wold-style-definition -Wstrict-prototypes -Wtraditional
-Wtraditional-conversion -Wdeclaration-after-statement -Wpointer-sign}
-Wmissing-parameter-name @r{(C/ObjC only)}
-Wmissing-parameter-type @r{(C/ObjC only)}
-Wold-style-declaration @r{(C/ObjC only)}
+-Wmultiple-parameter-fwd-decl-lists @r{(C/ObjC only)}
-Woverride-init @r{(C/ObjC only)}
-Wredundant-move @r{(C++ and Objective-C++ only)}
-Wshift-negative-value @r{(in C++11 to C++17 and in C99 and newer)}
equivalent to @samp{(void)} in that case, but is considered an
old-style definition for older standards.
+@opindex Wmultiple-parameter-fwd-decl-lists
+@opindex Wno-multiple-parameter-fwd-decl-lists
+@item -Wmultiple-parameter-fwd-decl-lists @r{(C and Objective-C only)}
+Warn if more than one list of forward declarations of parameters
+appears in a function prototype.
+This warning is also enabled by @option{-Wextra}.
+
@opindex Wdeprecated-non-prototype
@opindex Wno-deprecated-non-prototype
@item -Wdeprecated-non-prototype @r{(C and Objective-C only)}
--- /dev/null
+/* { dg-do compile } */
+/* { dg-options "-Wmultiple-parameter-fwd-decl-lists" } */
+
+void f(int n, int m; int n, int m);
+void g(int n; int m; int n, int m); /* { dg-warning "more than one list of forward declarations" } */
+void h(int n; int n; int n); /* { dg-warning "more than one list of forward declarations" } */