[Prev][Next][Index]

Fortran parser bug




I believe I have found a bug in the Fortran parser; the bug makes it
impossible for the call graph analyzer (which I am extending in various
ways) to deal with Fortran functions.

Consider:

      program main
      integer x

      x = foo( 1 )
      end

      integer function foo( n )
      integer n

      return n**2
      end

When traversing the symbol table for this program, two distinct symbols are
introduced for the function foo: one at the point of call, one at the
function header. Both symbols have type FUNCTION_NAME. 

Even if there are more calls to foo, only those two symbols are created.

My understanding of Fortran is that one is neither required nor able to
declare a function "forward" if it is defined after its use, and since
the symbol foo in both contexts names the function, it should be the same
symbol.

This problem does not appear to exist with subroutines.

--lars




Follow-Up(s):