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 Janus,


Janus Weil wrote:
SUBROUTINE a
 abstract interface
   subroutine abc(x)
     real x
   end subroutine
 end interface
 procedure(abc) :: abc2
entry abc2(x)
 real x
 x = 0
end subroutine
end

This program also crashes with my latest patch. My first thought would be that the solution is as easy as adding a line

conf (procedure, entry)

in symbol.c (check_conflict). At least this does the job for the above
code, giving an error message a la "PROCEDURE attribute conflicts with
ENTRY attribute", thereby preventing the ICE.

Well, the right thing to do depends on what the standard says. I've little doubt that the testcase is illegal, and then your fix would be right, but this has to be justified in the standard which I don't have handy right now. FWIW, PROCEDURE parallels EXTERNAL, and you can't declare an entry EXTERNAL in the same program unit.


But still I'm not completely sure if this solves all possible problems
with "ENTRY" and if it would reject any legal code. At least sth like
the following works fine:

function f(x) result(r)
implicit none
real r,x
r=2.*x
return
entry g(x) result(r)
r=3.*x
return
end function

program prog
procedure(real):: f,g
!real,external:: f,g
print *,f(5.)
print *,g(5.)
end program

It works with EXTERNAL as well as PROCEDURE, and my
"conf(procedure,entry)"-check does no harm since the main program just
doesn't know it the external symbols f and g are implemented as a
FUNCTION or an ENTRY.

Completely agreed.


I will post a new patch with this fix, a test case for it and a
"gfc_add_proc" function soon, provided you don't find any further
issues with ENTRY. And maybe we need some more conflict checks with
other attributes? Up to now I really only checked for those with are
accepted by "match_attr_spec". Any ideas?

There's not much I can think of. Maybe initialization can cause trouble? Say one of the following examples:
program prog
data f/1.0/
procedure(real):: f,g
!data f/1.0/
!real :: f = 1.0
end program


BTW I'll be on vacation and offline beginning Thursday, so don't waste your time waiting for my comments during my absence ;-)

Cheers,
- Tobi


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