Hi Chris,

On Sun, Sep 07, 2025 at 02:38:20PM +0100, Christopher Bazley wrote:
> >     alx@debian:~/tmp$ cat fwd.c | nl
> >          1  void f(int n, int n; int n);
> >          2  void g(int n; int n; int n);
> >          3  void h(int n, int m; int n, int m);
> >          4  void i(int n; int m; int n, int m);
> >     alx@debian:~/tmp$ gcc -S -Wall -Wextra fwd.c
> >     fwd.c:1:19: error: redefinition of parameter ‘n’
> >         1 | void f(int n, int n; int n);
> >           |               ~~~~^
> >     fwd.c:1:12: note: previous definition of ‘n’ with type ‘int’
> >         1 | void f(int n, int n; int n);
> >           |        ~~~~^
> >     fwd.c:1:12: error: parameter ‘n’ has just a forward declaration
> >     alx@debian:~/tmp$ gcc -S -Wall -Wextra -Wpedantic fwd.c
> >     fwd.c:1:19: error: redefinition of parameter ‘n’
> >         1 | void f(int n, int n; int n);
> >           |               ~~~~^
> >     fwd.c:1:12: note: previous definition of ‘n’ with type ‘int’
> >         1 | void f(int n, int n; int n);
> >           |        ~~~~^
> >     fwd.c:1:1: warning: ISO C forbids forward parameter declarations 
> > [-Wpedantic]
> >         1 | void f(int n, int n; int n);
> >           | ^~~~
> >     fwd.c:1:12: error: parameter ‘n’ has just a forward declaration
> >         1 | void f(int n, int n; int n);
> >           |        ~~~~^
> >     fwd.c:2:1: warning: ISO C forbids forward parameter declarations 
> > [-Wpedantic]
> >         2 | void g(int n; int n; int n);
> >           | ^~~~
> >     fwd.c:3:1: warning: ISO C forbids forward parameter declarations 
> > [-Wpedantic]
> >         3 | void h(int n, int m; int n, int m);
> >           | ^~~~
> >     fwd.c:4:1: warning: ISO C forbids forward parameter declarations 
> > [-Wpedantic]
> >         4 | void i(int n; int m; int n, int m);
> >           | ^~~~
> > 
> > -  We want to keep the error in line 1, right?
> 
> Yes, although "parameter ‘n’ has just a forward declaration" is misleading.
> I am not sure exactly what is causing that. It seems critical to understand
> it even if it proves difficult to remove.

I'll check it.

> > -  The diagnostic in lines 2 & 4 should be reworded, and enabled by -Wextra.
> > -  I should remove the diagnostic in line 3, at least for >C23.
> > 
> > Right?  I can do that.
> 
> Sorry, when I wrote "implement n3681", I didn't mean that literally because
> it isn't possible to remove diagnostics for >C23 unless/until WG14 accepts
> forward parameter declarations into C2Y. I expect GCC's maintainers to
> reject any change that removes "warning: ISO C forbids forward parameter
> declarations" under any circumstance in which it is currently produced --

Yup; I'll have that part prepared for the future, but not present it now
for obvious reasons.  It'll remain under -Wpedantic.

> including in the presence of any new warning about deprecation of support
> for multiple forward parameter declaration lists.
> 
> What I was really thinking about was changes like the proposed extended
> syntax, which could be accepted (but isn't):
> 
> void g( ; int x);
> void h( ; );
> void i( ; ...);

Ahhh, thanks for the reminder!

BTW, I'm wondering about the following:

        alx@debian:~/tmp$ cat fwd.c
        void j(void; int x);
        void k(void; void);
        void l(void; ...);
        alx@debian:~/tmp$ gcc fwd.c
        fwd.c:1:8: error: parameter ‘({anonymous})’ has just a forward 
declaration
            1 | void j(void; int x);
              |        ^~~~
        fwd.c:2:14: error: ‘void’ must be the only parameter
            2 | void k(void; void);
              |              ^~~~
        fwd.c:2:8: error: parameter ‘({anonymous})’ has just a forward 
declaration
            2 | void k(void; void);
              |        ^~~~

These should be supported as well (even with more priority than empty
lists).  (I never liked C23's decission of allowing () as synonyn for
(void).)

> Also "Both declarations shall specify compatible types before adjustment and
> have the same storage-class specifiers". For example, the following examples
> could be rejected (but aren't):
> 
> void l(int x[3]; int x[4]); // incompatible types before adjustment
> void m(int *x; int x[]); // incompatible types before adjustment
> void p(register int x; int x); // different storage class
> 
> I think this second point is the one of most relevance to your proposed
> extension to _Countof, isn't it?

Yup, I think so.

> > > since one of their
> > > objections was that they do not have enough resources to implement C
> > > language features that are not useful in C++. (This particular feature
> > > is not useful because C++ does not support dependent types, so
> > > obviously they are going to resist it.)
> > > 
> > > I do not know whether Alejandro has time to do this work, but it seems
> > > like the best way to determine whether Clang's objections have any
> > > real substance, and to prove that the feature is feasible and useful
> > > as specified in N3681.
> > I have time; and Aaron would probably help me with doubts if I try.
> 
> He is against the feature, but there may be others in the Clang community
> who could help.

No, I talked with Aaron in Brno, and he seemed happy to help me.  While
he doesn't like the feature, he likes having me as a contributor, which
might be enough for him to help with learn Clang internals.

> > I just need energy to resist the pain of reading and writing C++ code.
> 
> Of course GCC is also written in C++, although less noticeably.

Yeah, in theiry.  So far, I didn't notice, other than in the .cc file
extensions.  It's the kind of C++ I'd write, if I were forced to write
C++.  :-)


Have a lovely night!
Alex

-- 
<https://www.alejandro-colomar.es>
Use port 80 (that is, <...:80/>).

Attachment: signature.asc
Description: PGP signature

Reply via email to