[flang-commits] [flang] [FLANG][Semantics] Add check for DATA statement in interface body. (PR #221397)

Eugene Epshteyn via flang-commits flang-commits at lists.llvm.org
Mon Sep 14 11:05:00 PDT 2026


https://github.com/eugeneepshteyn approved this pull request.

LGTM. Could you please add more tests for different variations of this error:
```fortran
module m
  interface
    module subroutine ms(x)
      integer :: x
      integer :: y
      !ERROR: A DATA statement may not appear in an interface body
      data y /1/
    end subroutine
  end interface
end module

module mop
  type t
    integer :: i
  end type
  interface operator(+)
    function add(a, b) result(r)
      import t
      type(t), intent(in) :: a, b
      type(t) :: r
      integer :: w
      !ERROR: A DATA statement may not appear in an interface body
      data w /3/
    end function
  end interface
end module

interface
  subroutine s
    integer :: x
    !ERROR: A DATA statement may not appear in an interface body
    data x /1/
  end subroutine
  pure subroutine sp
    integer :: z
    !ERROR: A DATA statement may not appear in an interface body
    data z /2/
  end subroutine
  subroutine cb
    real :: v
    common /blk/ v
    !ERROR: A DATA statement may not appear in an interface body
    data v /0./
  end subroutine
  subroutine ok
    ! Legal: initialization in a type declaration statement is not a data-stmt;
    ! it is simply a specification with no effect (F2023 15.4.3.2 p6).
    integer :: v = 1
  end subroutine
end interface

end
```

https://github.com/llvm/llvm-project/pull/221397


More information about the flang-commits mailing list