https://gcc.gnu.org/bugzilla/show_bug.cgi?id=121563

--- Comment #7 from Christopher Bazley <Chris.Bazley at arm dot com> ---
It looks as though parameter forward declarations aren't marked as such until a
; is encountered by the parser, therefore a parameter forward declaration is
treated like an ordinary parameter declaration for the purpose of detecting
redeclaration of parameters. (push_parm_decl is called before
mark_forward_parm_decls in c_parser_parms_list_declarator.)

This is what I expected when I wrote
https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3433.pdf and it is one of
several reasons I had for preferring a single semicolon-terminated list of
forward parameter declarations: forward parameter declarations are still
parameter declarations and not block-scope declarations, therefore they
shouldn't have the same syntax as block-scope declarations (otherwise void
f2a(int x, x; x) really would be valid).

Consequently, the syntax proposed by N3433 implies that a forward declaration
list is parsed like an ordinary parameter declaration list. 

The prevailing sentiment in WG14 at the moment seems to be that code which
looks as though it has a bug in it (e.g. useless and has no conceivable reason
to have been written like that) should be diagnosed. Given that forward
declaring the same parameter twice is useless, diagnosing it seems desirable.

On the other hand, I'm finding it difficult to imagine circumstances in which
forward-declaring one parameter twice instead of forward-declaring two
parameters would not cause other diagnostic messages. I think you'd need at
least two bugs, e.g.

int yin;
void f(int xin; int xin; // should be diagnosed but isn't
       int x[xin], int y[yin], int xin, int yin);

Reply via email to