Skip to content

[flang][Semantics] Semantic error in Fortran code due to recursive reference in specification expression #106705

@inaki-amatria

Description

@inaki-amatria
  • flang-new version is: flang-new version 20.0.0git (https://github.com/llvm/llvm-project.git 46fe36a4295f05d5d3731762e31fc4e6e99863e9)
  • Reduced test case is:
! foo.f90

module foo
  real :: qux(10, 10, 10)

  interface
    module subroutine bar(i)
    end
    module function baz()
    end
  end interface
end

submodule (foo) foo_impl
  contains
    module procedure bar
      qux(i, i, i) = baz()
    end
    module procedure baz
    end
end
  • flang-new invocation is: flang-new foo.f90
  • Expected behavior is: The code compiles sucessfully without errors, as baz should be accessible through host association in bar.
  • Actual behavior: Compilation fails with the following error:
error: Semantic errors in /foo.f90
foo.f90:17:22: error: The module function 'baz' may not be referenced recursively in a specification expression
        qux(i, i, i) = baz()
                       ^^^^^
  • Additional information: Reordering the definitions of the procedures in the submodule seems to work around the issue for now.

Metadata

Metadata

Assignees

Labels

bugIndicates an unexpected problem or unintended behaviorflang:frontend

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions