Hi Thomas,

while the patch looks ok to me, why did you not choose to generate a "22.7.2
Variable-Length Parameter Lists"

https://www.gnu.org/software/c-intro-and-ref/manual/html_node/Variable-Number-of-Arguments.html

when the arguments differ? Then its the callee responsibility to figure
stuff out. Just out of curiosity. Is this prohibited by any standard? My
question is just out of interest. No need to change the patch. Having a warning
is better, then running into "WTF?".

Look good to me, ok for mainline.

Thanks for the patch,
        Andre

On Mon, 3 Mar 2025 22:50:16 +0100
Thomas Koenig <tkoe...@netcologne.de> wrote:

> Hello world,
>
> this patch is a bit more complicated than originally envisioned.
>
> The problem was that we were not handling external dummy arguments
> with -fc-prototypes-external. In looking at this, I found that we
> were not warning about external procedures with different argument
> lists.  This can actually be legal (see the two test cases) but
> creates a problem for the C prototypes: If we have something like
>
> subroutine foo(a,n)
>    external a
>    if (n == 1) call a(1)
>    if (n == 2) call a(2,3)
> end subroutine foo
>
> then, pre-C23, we could just have written out the prototype as
>
> void foo_ (void (*a) (), int *n);
>
> but this is illegal in C23. What to do?  I finally chose to warn
> about the argument mismatch, with a new option. Warn only because the
> code above is legal, but include in -Wall because such code seems highly
> suspect.  This option is also implied in -fc-prototypes-external. I also
> put a warning in the generated header file in that case, so users
> have a chance to see what is going on (especially since gcc now
> defaults to C23).
>
> Regression-tested.
>
> Comments?  Suggestions for better wordings?  Is -Wall too strong,
> should this be -Wextra (but then nobody would see it, probably...)?
> OK for trunk?
>
> Best regards
>
>       Thomas


--
Andre Vehreschild * Email: vehre ad gmx dot de

Reply via email to