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

Sean Santos <quantheory at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |quantheory at gmail dot com

--- Comment #12 from Sean Santos <quantheory at gmail dot com> ---
I think Tobias already has this figured, but my view of this was as follows.

These define statement functions yielding 7:

--- Example 1 ---

two() = 7
end

--- Example 2 ---

module foo
contains
  function two()
    integer, pointer  :: two
    allocate(two)
  end function two

  subroutine bar()
    ! Fortran 2008 (12.6.4) says that this is necessary to hide
    ! the host-associated declaration
    integer :: two
    two() = 7
  end subroutine bar
end module foo

These refer to the pointer function:

--- Example 1 ---

two() = 7
contains
  function two ()
    integer, pointer  :: two
    allocate(two)
  end function two
end

--- Example 2 ---

module foo
contains
  function two ()
    integer, pointer  :: two
    allocate(two)
  end function two
end module

program
use foo
two() = 7
end program

--- Example 3 ---

module foo
contains
  function two()
    integer, pointer  :: two
    allocate(two)
  end function two

  subroutine bar()
    two() = 7
  end subroutine bar
end module foo

And these are not allowed at all based on 11.2.2.8 and 16.3.1.3, because they
result in a name clash:

--- Example 1 ---

integer :: two
two() = 7
contains
  function two ()
    integer, pointer  :: two
    allocate(two)
  end function two
end

--- Example 2 ---

module foo
contains
  function two ()
    integer, pointer  :: two
    allocate(two)
  end function two
end module

program
use foo
integer :: two
two() = 7
end program

Reply via email to