Importing entities not existing, not importing existing

Consider the two programs:

  interface
     subroutine s(f)
       integer, parameter :: k=kind(0)
       interface
          function f()
            import k
          end function f
       end interface
     end subroutine s
  end interface
end



  integer, parameter :: k=kind(0)

  interface
     subroutine s(f)
       interface
          function f()
            import k
          end function f
       end interface
     end subroutine s
  end interface
end

In the first program the inner interface body’s host scope has an entity k. pgfortran 17.10 does not allow that to be imported.

In the second program the inner interface body’s host scope hasn’t an entity k, but the compiler still accepts the import statement.

This was replicated and reported as TPR 25085.

dave