[flang-commits] [PATCH] D157346: [flang] Allow reference to earlier generic in later interface

Peter Klausler via Phabricator via flang-commits flang-commits at lists.llvm.org
Mon Aug 7 15:37:39 PDT 2023


klausler created this revision.
klausler added a reviewer: PeteSteinfeld.
klausler added a project: Flang.
Herald added subscribers: jdoerfert, mgrang.
Herald added a project: All.
klausler requested review of this revision.

Name resolutions defers all resolution and checking of specific procedures
in non-type-bound generic interfaces to the end of the specification part.
This prevents expression analysis of references to generic functions in
specification expressions in interfaces from resolving.

Example (now a new test case in modfile07.f90):

  module m12
    interface generic
      module procedure specific
    end interface
    interface
      module subroutine s(a1,a2)
        character(*) a1
        character(generic(a1)) a2   ! <--
      end
    end interface
   contains
    pure integer function specific(x)
      character(*), intent(in) :: x
      specific = len(x)
    end
  end

The solution is to partially resolve specific procedures as they are
defined for each generic, when they can be resolved, with the final
pass at the end of the specification part to finish up any forward
references and emit the necessary error messages.

Making this fix caused some issues in module file output, which have
all been resolved by making this simplifying change: generics are
now all emitted to module file specification parts as their own
group of declarations at the end of the specification part,
followed only by namelists and COMMON blocks.


https://reviews.llvm.org/D157346

Files:
  flang/lib/Semantics/mod-file.cpp
  flang/lib/Semantics/resolve-names.cpp
  flang/test/Semantics/modfile07.f90
  flang/test/Semantics/modfile32.f90
  flang/test/Semantics/modfile33.f90
  flang/test/Semantics/modfile38.f90
  flang/test/Semantics/modfile39.f90
  flang/test/Semantics/modfile44.f90
  flang/test/Semantics/resolve15.f90
  flang/test/Semantics/resolve25.f90
  flang/test/Semantics/resolve77.f90

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D157346.547981.patch
Type: text/x-patch
Size: 26442 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/flang-commits/attachments/20230807/92d3f9fc/attachment-0001.bin>


More information about the flang-commits mailing list