Nvfortran import all symbols to child submodule from a module used by its parent module

Example 1, Shouldn’t pass

module m1
  implicit none
  integer :: i1, i2
end module m1

module m2
  use m1, only: i1
  implicit none
  interface
    module subroutine sub()
    end subroutine sub
  end interface
end module m2

submodule(m2) sm
  implicit none
contains
  subroutine sub()
    use m1, only: i1
    i2 = 1 ! i2 shouldn't be available
  end subroutine sub
end submodule sm

Example2, threw a severe error:

module m1
  implicit none
  integer :: i1, i2
end module m1

module m2
  use m1, only: i1
  implicit none
  integer :: i2
  interface
    module subroutine sub()
    end subroutine sub
  end interface
end module m2

submodule(m2) sm
  implicit none
contains
  subroutine sub()
    use m1, only: i1
    i2 = 1 ! i2 here is obviously the one from parent module m2
  end subroutine sub
end submodule sm

error message:

NVFORTRAN-S-0155-i2 is use-associated from modules m2 and m1, and cannot be accessed (nvfortran_bug.f90: 21)
  0 inform,   0 warnings,   1 severes, 0 fatal for sub

Thanks mehdi.chinoune. I’ve filed an issue report (TPR #29957) and sent it to our engineers for further investigation.

-Mat