[PATCH] Fortran: improve compile-time checking of character dummy arguments [PR93330]
Jerry D
jvdelisle2@gmail.com
Fri Aug 29 00:05:23 GMT 2025
On 8/28/25 1:51 PM, Harald Anlauf wrote:
> Dear all,
>
> the attached patch tries to improve diagnostics at compile time
> for character arguments in various ways:
>
> - we did unconditionally give a warning for too short character
> actual arguments passed to a scalar dummy; we now give an error
> when -std=f* is specified. The warning is retained for
> -std=legacy/gnu as several testcases depend on it.
>
> - if the actual argument has length zero, no warning was given.
> This had been remedied.
>
> - if a character actual argument is longer than the dummy, we now
> give a truncation warning if -Wcharacter-truncation is given.
>
> - If a character formal argument has the pointer or allocatable
> attribute, or is an array that is not assumed or explicit size,
> we now generate an error by default unless -std=legacy is
> specified, which falls back to just giving a warning as before.
> (One testcase depends on it.)
>
> The errors emitted as described above have been checked to be
> consistent with NAG. :-)
>
> There is one thing where we (still?) deviate from F2018:15.5.2.4.
> The standard text explicitly mentions default character kind and
> C character kind in several contexts, which could be interpreted
> as excluding kind=4 character. However, I do not see why this
> should be the case - there is no actual technical reason, and
> also NAG handles kind=4 character the same as kind=1 character
> in the tests. If someone feels strongly about it, we could
> make an interp request to resolve this. I would consider this
> a gfortran extension for the time being.
>
> Regtested on x86_64-pc-linux-gnu. OK for mainline?
>
> Thanks,
> Harald
>
Yes, OK Harald.
Thanks for the work.
Jerry
More information about the Fortran
mailing list