[Patch, Fortran] PR39850: Too strict checking for procedures as actual argument

Janus Weil janus@gcc.gnu.org
Sun Jun 21 08:42:00 GMT 2009


>> It was done wrongly in two test cases in the testsuite
>> (interface_21.f90 and proc_decl_8.f90).
>>
> No, that was done correctly in those cases. Contrary to this PR there is a
>   IMPLICIT NONE
> in interface_21.f90 and proc_decl_8.f90. Thus an
>   EXTERNAL foo
> can only refer to a SUBROUTINE.

Oops, apparently I missed this subtlety.


> In the PR 39850 (comment 0), the code has no "IMPLICIT NONE" and thus
>   EXTERNAL foo
> means that "foo" can bei either a subroutine or a function. If "foo" is
> now passed as actual argument, it should work if the dummy argument
> accepts either a subroutine or a function (which returns a REAL) - or if
> it accepts either. Whether the dummy has an explicit interface or not
> does not play a rule.

Here goes my second attempt, which retains the error messages for
interface_21 and proc_decl_8, while avoiding the spurious error
message in the PR. I also extended the new test case interface_30.f90
a bit.


>> Regtested on x86_64-unknown-linux-gnu. Ok for trunk?
>>
> No for the reason outline above. If the actual argument is BT_UNKNOWN
> and attr.subroutine is not set, one should call gfc_set_default_type -
> then one can continue with checking whether ts.type/kind match.

Actually I don't think it would be correct to use
'gfc_set_default_type', since such a case could also be a subroutine
(which has no return type). Instead I use 'gfc_get_default_type' to
check if the symbol *could* get an implicit type, without actually
setting the type.

Regtested again. Ok now?

Cheers,
Janus


2009-06-21  Janus Weil  <janus@gcc.gnu.org>

	PR fortran/39850
	* interface.c (gfc_compare_interfaces): Take care of implicit typing
	when checking the function attribute. Plus another bugfix.


2009-06-21  Janus Weil  <janus@gcc.gnu.org>

	PR fortran/39850
	* gfortran.dg/interface_19.f90: Add 'cleanup-modules'.
	* gfortran.dg/interface_20.f90: Ditto.
	* gfortran.dg/interface_21.f90: Ditto.
	* gfortran.dg/interface_22.f90: Ditto.
	* gfortran.dg/interface_30.f90: New.
	* gfortran.dg/proc_ptr_11.f90: Fix invalid test case.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pr39850_v2.diff
Type: text/x-patch
Size: 2908 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/fortran/attachments/20090621/67c5b841/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: interface_30.f90
Type: text/x-fortran
Size: 605 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/fortran/attachments/20090621/67c5b841/attachment-0001.bin>


More information about the Fortran mailing list