This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH, Fortran] PROCEDURE declarations


Hi,

2007/9/3, Janus Weil <jaydub66@googlemail.com>:
> But in the case of ENTRY that wasn't enough. Without my patch, a
> conflict between ENTRY and EXTERNAL would be caught by:
>
>   if (attr->if_source || attr->contained)
>     {
>       conf (external, subroutine);
>       conf (external, function);
>     }
>
> But this check was a problem for PROCEDUREs, since they can have an
> explicit interface. In this code:
>
> abstract interface
>   subroutine abssub()
>   end subrouine
> end interface
> procedure(abssub)::p
>
> the symbol p would have the attributes PROCEDURE, EXTERNAL, SUBROUTINE
> and also attr->if_source=IFSRC_DECL, since it has an explicit
> interface. So the above check would give an error. Therefore I changed
> the if-clause to:
>
> if ((attr->if_source && !attr->procedure) || attr->contained)
>
> That does prevent the falsely issued error for "p".
> *But* it also makes useless the conflict-check for ENTRY and
> PROCEDURE, which then has to be done manually by "conf (procedure,
> entry)".
> I hope my way to deal with this stuff is ok and there is no logical
> error in my thinking.

I'm just a little confused right now: Is an EXTERNAL procedure allowed
to have an explicit interface? "Sure, why not" would be my spontaneous
answer. And I found nothing in the standard which would disallow it.
But then this conflict-check I was talking about doesn't really make
sense. Consider the following code:

subroutine s(x)
  real x
  print *," x = ",x
end subroutine

program p

interface
  subroutine s(x)
    real x
  end subroutine
end interface

!external s

call s(3.14)

end program

Without the EXTERNAL statement this runs like a charm. The F2003
standard has says the following in section 12.3.2.1:

"An interface body in a generic or specific interface block specifies
the EXTERNAL attribute and an explicit specific interface for an
external procedure or a dummy procedure."

Everything ok so far. But then if I add the line "external s", I get the error

external s
         1
Error: EXTERNAL attribute conflicts with SUBROUTINE attribute at (1)

The question is why. If I interpret the standard correctly, already
the INTERFACE statement implies the EXTERNAL attribute. But then the
explicit EXTERNAL statement should basically change nothing, or
perhaps trigger an error like "EXTERNAL attribute already specified".
But instead I get this error about a conflict with SUBROUTINE, which
apparently comes just from

>   if (attr->if_source || attr->contained)
>     {
>       conf (external, subroutine);
>       conf (external, function);
>     }

I suppose in this case we have if_source = IFSRC_IFBODY. Isn't this
check wrong then? Shouldn't it rather be something like

if (attr->if_source == IFSRC_DECL || attr->contained) ... ?

Hoping for answers,
Janus


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]