Hi Thomas,
Am 03.03.25 um 22:50 schrieb Thomas Koenig:
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
aren't we wasting memory here?
@@ -2023,6 +2023,10 @@ typedef struct gfc_symbol
scope. Used in the suppression of uninitialized warnings in
reallocation
on assignment. */
unsigned allocated_in_scope:1;
+ /* Set if an external dummy argument is called with different
argument lists.
+ This is legal in Fortran, but can cause problems with autogenerated
+ C prototypes for C23. */
+ unsigned ext_dummy_arglist_mismatch;
I assume you wanted a single bit instead of a full unsigned, i.e.:
+ unsigned ext_dummy_arglist_mismatch:1;
Harald