[patch, fortran] Fix PR 87689, wrong decls / ABI violation on POWER
Janne Blomqvist
blomqvist.janne@gmail.com
Mon Feb 18 13:08:00 GMT 2019
On Mon, Feb 18, 2019 at 2:51 PM Richard Biener
<richard.guenther@gmail.com> wrote:
> The patch looks good to me. I wonder how the frontend handles
> the 2nd call to doesntwork_p8 for
>
> program main
> implicit none
> character :: c
> character(len=20) :: res, doesntwork_p8
> external doesntwork_p8
> c = 'o'
> res = doesntwork_p8(c,1,2,3,4,5,6)
> res = doesntwork_p8(1,2)
> if (res /= 'foo') stop 3
> end program main
>
> at least I get no diagnostic and the patch suggests whatever call
> gets there first determines the backend-decl and its type? At least
> when I omit res = from the second call I get
>
> t.f:4:47:
>
> 4 | character(len=20) :: res, doesntwork_p8
> | 1
> ......
> 8 | call doesntwork_p8(1,2)
> |
> Error: ‘doesntwork_p8’ at (1) has a type, which is not consistent with
> the CALL at (2)
>
> Does the Fortran standard say anything in how the above case should be handled?
Without actually checking, I'm pretty sure a procedure is either a
function (something that returns a value) or a subroutine (does NOT
return a value, like a void function in C), but not both (some of the
intrinsics in gfortran can be called both as a function or a
subroutine, but that's a gfortran-specific extension (inherited from
g77, AFAIK), not part of the language, and only for some intrinsics
that the compiler handles in a special way, not a generic user-defined
procedure). So the example you show above is invalid.
--
Janne Blomqvist
More information about the Gcc-patches
mailing list