Reported by Arjan van Dijk, http://gcc.gnu.org/ml/fortran/2007-04/msg00367.html
gfortran rejects the following code with the error: "By-value argument at (1) is not allowed in this context" This is because the following check is matched: resolve.c, resolve_actual_arglist(): /* Intrinsics are still PROC_UNKNOWN here. However, since same file external procedures are not resolvable in gfortran, it is a good deal easier to leave them to intrinsic.c. */ if (ptype != PROC_UNKNOWN && ptype != PROC_DUMMY && ptype != PROC_EXTERNAL) However, in this case: ptype == PROC_MODULE. The following values are possible: PROC_UNKNOWN, PROC_MODULE, PROC_INTERNAL, PROC_DUMMY, PROC_INTRINSIC, PROC_ST_FUNCTION, PROC_EXTERNAL I have to think about which cases make sense and which don't. What speaks against allowing PROC_INTRINSIC, PROC_INTERNAL, PROC_ST_FUNCTION? Is there one which needs always be rejected? If yes, a test case would be nice. For PROC_INTERNAL I would argue it should be allowed: SUBROUTINE Grid2BMP(NX) INTEGER, INTENT(IN) :: NX call bmp_write(%val(nx)) contains subroutine bmp_write(nx) integer, intent(in) :: nx end subroutine bmp_write END SUBROUTINE Grid2BMP end For statement functions, I agree it should be invalid (for %VAL, %REF, %DESCR): SUBROUTINE Grid2BMP(NX) INTEGER, INTENT(IN) :: NX integer :: i,f f(i)=i**2 ! statement function i = f(%VAL(i)) END SUBROUTINE Grid2BMP This agrees with ifort which also rejects it. And for PROC_INTRINSIC: ifort rejects sin(%VAL(x)) as above (%VAL/%REF/%DESCR invalid in this context), gfortran has the error: "Argument list function at (1) is not allowed in this context". (I prefer Intel's error message.) At the moment, I don't see any intrinsic which would work with %VAL, but maybe I miss something. Is there an example for PROC_INTRINSIC or PROC_UNKNOWN which needs to be supported? Example: a) Longer example, see follow up email (URL above) b) short example (works if one moves the interface into the procedure body): module x interface subroutine bmp_write(nx) integer, intent(in) :: nx end subroutine bmp_write end interface contains SUBROUTINE Grid2BMP(NX) INTEGER, INTENT(IN) :: NX call bmp_write(%val(nx)) END SUBROUTINE Grid2BMP END module end -- Summary: %VAL rejected for PROC_MODULE and PROC_INTERNAL procedures Product: gcc Version: 4.3.0 Status: UNCONFIRMED Keywords: rejects-valid Severity: normal Priority: P3 Component: fortran AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: burnus at gcc dot gnu dot org http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31668