Hi!
Here's v2. It's still an RFC because I was unable to build GCC, due to
an unrelated build error in the master branch.
I assume this diagnostic should be added to ObjectC, just because most
diagnostics are shared between C and ObjectC. I don't know if this
affects ObjectC (I don't even know how to write a hello-world program in
that language).
Changes in v2:
- Added ChangeLog entries in the commit message.
- Minor changes in commit message.
- Remove braces in conditionals with a single statement.
- Use lowercase in diagnostic.
- Fix testsuite file name.
Have a lovely night!
Alex
Alejandro Colomar (1):
c, objc: Deprecate more than one list of forward declarations of
parameters
gcc/c-family/c.opt | 4 ++++
gcc/c/c-decl.cc | 16 +++++++++-------
gcc/doc/extend.texi | 2 +-
gcc/doc/invoke.texi | 13 ++++++++++++-
.../gcc.dg/Wmultiple-parameter-fwd-decl-lists.c | 6 ++++++
5 files changed, 32 insertions(+), 9 deletions(-)
create mode 100644 gcc/testsuite/gcc.dg/Wmultiple-parameter-fwd-decl-lists.c
Range-diff against v1:
1: fd77f2ea556 ! 1: c17fc8e7f0d c: Deprecate more than one list of forward
declarations of parameters
@@ Metadata
Author: Alejandro Colomar <[email protected]>
## Commit message ##
- c: Deprecate more than one list of forward declarations of parameters
+ c, objc: Deprecate more than one list of forward declarations of
parameters
+
+ Warn about this:
+
+ void f(int x; int x; int x);
- While this syntax is not standard, there's a certain degree of
consensus
- within the C Committee that, if this was ever standardized, there's a
- preference to have a single list of forward declarations of parameters.
This would allow eventually adding another semicolon in function
prototypes to separate a different feature.
@@ Commit message
-Wmultiple-parameter-fwd-decl-lists, which diagnoses uses of this
obsolescent syntax.
- Forward declarations of parameters are a rarely used feature, AFAIK, so
- this shouldn't be problematic in -Wextra. Eventually, we may want to
- move this into a default diagnostic, and later an error.
+ Forward declarations of parameters are a rarely used feature, AFAIK,
+ (and having more than one would be even rarer) so this shouldn't be
+ problematic in -Wextra. Eventually, we may want to move this into
+ a default diagnostic, and later an error.
+
+ 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/invoke.texi: Document the new
+ -Wmultiple-parameter-fwd-decl-lists.
+
+ gcc/testsuite/ChangeLog:
+
+ * gcc.gd/Wmultiple-parameter-fwd-decl-lists.c: New test.
Cc: Christopher Bazley <[email protected]>
Cc: Martin Uecker <[email protected]>
@@ gcc/c/c-decl.cc: mark_forward_parm_decls (void)
struct c_binding *b;
- if (pedantic && !current_scope->warned_forward_parm_decls)
-+ 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 are
an obsolescent feature");
-+ }
-+ if (pedantic && !current_scope->had_forward_parm_decls)
- {
- pedwarn (input_location, OPT_Wpedantic,
- "ISO C forbids forward parameter declarations");
+- {
+- 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 are
an obsolescent feature");
++ 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)
@@ gcc/doc/invoke.texi: is not considered an old-style definition in C23
mode, beca
@opindex Wno-deprecated-non-prototype
@item -Wdeprecated-non-prototype @r{(C and Objective-C only)}
- ## gcc/testsuite/gcc.dg/Wold-style-fwd-declaration.c (new) ##
+ ## gcc/testsuite/gcc.dg/Wmultiple-parameter-fwd-decl-lists.c (new) ##
@@
+/* { 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" } */
++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" } */
--
2.50.1