]> git.ipfire.org Git - thirdparty/gcc.git/commit
c, objc: Add -Wmultiple-parameter-fwd-decl-lists
authorAlejandro Colomar <alx@kernel.org>
Fri, 26 Sep 2025 19:27:28 +0000 (19:27 +0000)
committerJoseph Myers <josmyers@redhat.com>
Fri, 26 Sep 2025 19:28:24 +0000 (19:28 +0000)
commit33c35b7f4c1894cb197903310b7b7bff19205f35
tree1bde2b1952f8bf1b2b6884f25ebd109409af5de6
parente6b4908c0402635c05e98bb1add0c4eaac44a02b
c, objc: Add -Wmultiple-parameter-fwd-decl-lists

Warn about this:

void f(int x; int x; int x);

Add a new diagnostic, -Wmultiple-parameter-fwd-decl-lists, which
diagnoses uses of this obsolescent syntax.

Add this diagnostic in -Wextra.

Forward declarations of parameters are very rarely used.  And functions
that need two forward declaractions of parameters are also quite rare.
This combination results in this code almost not existing in any code
base, which makes adding this to -Wextra okay.  FWIW, I've tried finding
such code using a code search engine, and didn't find any cases (but the
regex for that isn't easy to writei, so I wouldn't trust it).

gcc/c-family/ChangeLog:

* c.opt: Add -Wmultiple-parameter-fwd-decl-lists

gcc/c/ChangeLog:

* c-decl.cc (c_scope): Rename {warned > had}_forward_parm_decls.
(mark_forward_parm_decls): Add
-Wmultiple-parameter-fwd-decl-lists.

gcc/ChangeLog:

* doc/extend.texi: Clarify documentation about lists of
parameter forward declarations, and mention that more than one
of them are unnecessary.
* doc/invoke.texi: Document the new
-Wmultiple-parameter-fwd-decl-lists.

gcc/testsuite/ChangeLog:

* gcc.dg/Wmultiple-parameter-fwd-decl-lists.c: New test.

Signed-off-by: Alejandro Colomar <alx@kernel.org>
gcc/c-family/c.opt
gcc/c/c-decl.cc
gcc/doc/extend.texi
gcc/doc/invoke.texi
gcc/testsuite/gcc.dg/Wmultiple-parameter-fwd-decl-lists.c [new file with mode: 0644]