http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39290

--- Comment #9 from Tobias Burnus <burnus at gcc dot gnu.org> 2013-04-29 
12:40:50 UTC ---
(In reply to comment #8)
> There are a quite a few problems it seems:
>  1. we rely on s1->attr.function _and_ s2->attr.function being set, which is
> obviously not the case with implicit typing.

I think the simplest fix is to do the following:

If (dummy->attr.function && actual_argument->attr.external
    && !actual_argument->attr.subroutine)
  Implicitly-type-the-actual-argument;

The Fortran standard requires that all external procedures which are used as
actual argument have the "external" attribute. (To distinguish them from
variables.)

And "12.4.3.4.5 Restrictions on generic declarations" ensures that either a
subroutine or a function but never both is used for a given argument:

"Two dummy arguments are distinguishable if
* one is a procedure and the other is a data object,
* they are both data objects or known to be functions, and neither is TKR
compatible with the other,
* one is a function with nonzero rank and the other is not known to be a
function.
[...]"


One just has to ensure that
  external :: sub
  call foo(sub)
doesn't get the function attribute and typed when first checking "one" for a
possible match:
  interface foo
    subrouine one(f,y)
      real, external :: f
      integer :: y
    end
    subroutine two(s)
      external :: s
    end
  end interface


BTW: When updating this, one can also implement the new Fortran 2008 feature:
"ALLOCATABLE and POINTER attributes are used in generic resolution.
Procedureness of a dummy argument is used in generic resolution." (I think the
first one is already implemented.) -> F2008, 12.4.3.4.5

Reply via email to