https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114280

            Bug ID: 114280
           Summary: ASSOCIATE fails with inquiry references when selector
                    function not yet parsed.
           Product: gcc
           Version: 13.2.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: pault at gcc dot gnu.org
  Target Milestone: ---

Fails identically back to 6.4.1 at least:

  implicit none
  type t
     real :: re
  end type t
  call foo
contains
  subroutine foo ()
    associate (x => bar1())
      print *, x%im          ! Has no IMPLICIT type
    end associate

    associate (x => bar1())
      print *, x%re          ! Invalid character in name
    end associate

    associate (x => bar2())
      print *, x%re          ! Invalid character in name
    end associate

    associate (x => bar3())
      print *, x%len          ! Has no IMPLICIT type
    end associate
  end
  complex function bar1 ()
    bar1 = cmplx(-42., 1.)
  end
  type(t) function bar2 ()
    bar2% re = 42.
  end
  character(8) function bar3 ()
    bar3 = "Nice one!"
  end
end

Works if:
(i) subroutine foo is placed after functions bar[1-3]; or
(ii) if intrinsics real, imag and len are used instead of inquiry references
and component 're' is renamed.

This bug appears for the same reason as PR99065.

Paul


Paul

Reply via email to