This is the mail archive of the fortran@gcc.gnu.org mailing list for the GNU Fortran 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]

[Patch, fortran] PR54107: ICE on recursive interfaces and PR54195: symbol bogusly inserted twice in the interface.


Hello,

The following patches fix both PR54107 and PR54195.
- In PR54107(comment 26), the procedure result is a procedure pointer
whose interface is the procedure itself, which leads to an infinite
recursion during resolution.
- In PR54195, a type's type bound procedures are resolved twice, leading
to a symbol being added twice in an interface and rejected.

The fix, as discussed in PR54195, adds a flag to mark a symbol as
resolved.  This leads to two regressions.  For class_20, a check to skip
result symbols had to be removed (which was there to avoid duplicated
resolution).  For initialization_27 (among a few others) the code adding
the default initialization code was guarded by a check against
gfc_current_ns, which always ended triggering when there was more than
one resolution but may not anymore.  The fix removes it; I checked that
gfc_current_ns wasn't used in the following code.

The second fix makes the recursion through resolve_symbol, so that the
flag just added triggers and PR54195 is fixed.

Regression tested on x86_64-unknown-linux-gnu. OK for trunk?

Mikael




Attachment: pr54107_c26.CL
Description: Text document

Attachment: pr54107_c26.diff
Description: Text document

! { dg-do compile }
!
! PR fortran/54107
! The compiler used to ICE on recursive interfaces.

module m
 contains
  function foo() result(r1)
    procedure(foo), pointer :: r1 
  end function foo

  function bar() result(r2)
    procedure(baz), pointer :: r2
  end function bar

  function baz() result(r3)
    procedure(bar), pointer :: r3
  end function baz
end module m

Attachment: pr54195.CL
Description: Text document

Attachment: pr54195.diff
Description: Text document

! { dg-do compile }
!
! PR fortran/54195
! The compiler used to diagnose a duplicate entity in the assignment interface
! because NC was resolved twice.
!
! Contributed by Damian Rouson <damian@rouson.net>

module import_clashes_with_generic

  type ,abstract :: foo
  contains
    procedure :: unary
    generic :: operator(-) => unary
  end type

  abstract interface
    integer function bar()
      import :: foo
    end function
  end interface

contains

  integer function unary(rhs)
    class(foo) ,intent(in) :: rhs
  end function

end module

! { dg-do compile }
!
! PR fortran/54195
! The compiler used to diagnose a duplicate entity in the assignment interface
! because NC was resolved twice.
!
! Contributed by Andrew Benson <abenson@obs.carnegiescience.edu>

module gn

  implicit none

  type :: nc
   contains
     procedure :: assign => nca
     generic   :: assignment(=) => assign
  end type

  type, extends(nc) :: ncb
   contains
     procedure , nopass :: tis => bf
  end type

contains

  subroutine nca(to,from)
    class(nc), intent(out) :: to
    type(nc), intent(in) :: from
  end subroutine

  logical function bf()
    bf=.false.
  end function

end module


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