This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug fortran/39850] Too strict checking for procedures as actual argument
- From: "burnus at gcc dot gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 20 Jun 2009 17:44:19 -0000
- Subject: [Bug fortran/39850] Too strict checking for procedures as actual argument
- References: <bug-39850-13404@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Comment #4 from burnus at gcc dot gnu dot org 2009-06-20 17:44 -------
Regarding comment 0: I believe the program is valid
Regarding proc_decl_8.f90 and interface_21.f90: The programs are obviously
invalid - and the error message is OK.
* * *
In case of proc_decl_8.f90/interface_21.f90: The actual argument "foo" can only
be a SUBROUTINE as "IMPLICIT NONE; external foo" has been used, but the dummy
argument requires a FUNCTION.
That violates (12.4.1.3): "If the interface of the dummy argument is explicit,
the characteristics listed in 12.2 shall be the same for the associated actual
argument" as 12.2 has "The characteristics of a procedure are the
classification of the procedure as a function or subroutine"
* * *
In case of comment 0: The dummy argument is a function (with an implicit
interface) and the actual argument is a procedure (with an implicit interface),
which can _either_ be a subroutine _or_ an implicitly as real typed function.
If the actual procedure is a function, this fulfilled and the program is valid.
(As the call makes clear that "func" is a function, a subsequent use of "func"
as subroutine is invalid.)
* * *
For completeness: Passing an actual argument with an implicitly defined
interface to a procedure with has an explicit interface: That is valid as long
a) as the standard does not mandate the use of an explicit interface
b) and the procedure which is associated with the dummy argument has an
interface which is conform with the dummy.
[One has to be careful whether "actual argument" refers to the entity in the
procedure reference or the entity that is associated with the dummy argument.
They can be split as in the following case: When the dummy is not a pointer:
Here, the entity used in the procedure reference can be a pointer, but the
entity associated with the dummy is then not the pointer but the target of the
pointer (cf. p.473 in The Fortran 2003 Handbook).
Something related applies here: The entity associated with the dummy argument
needs to have a conforming interface, but the entity used in the procedure
reference can have an implicit interface.]
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39850