llvm-project icon indicating copy to clipboard operation
llvm-project copied to clipboard

[flang][Fortran 2003] unimplemented semantic checks: type bound procedure 2

Open PeixinQiao opened this issue 4 years ago • 3 comments

subroutine s()
  interface
    subroutine real_info()
    end
  end interface
  type mt
   contains
    procedure :: info => real_info
  end type
  type mt2
    type(mt) :: t1(2)
  end type
  type mt3
    type(mt2) :: t2(2)
  end type
  type mt4
    type(mt3) :: t3(2)
  end type
  type(mt4) :: t(2)

  call sub1(t%t3%t2%t1%info)
end
$ flang-new -fc1 test.f90 

fatal internal error: PASS argument missing at /home/.../llvm-project/flang/lib/Evaluate/characteristics.cpp(478)
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.

Temprorily assign this to myself. Please feel free to take up this when anyone has time to do it. I will say here if I start working on this.

PeixinQiao avatar Jun 02 '22 02:06 PeixinQiao

@llvm/issue-subscribers-flang-frontend

llvmbot avatar Jun 02 '22 02:06 llvmbot

FYI: The latest Flang driver now produces:

error: Semantic errors in 55825.f
./55825.f:8:18: error: Procedure binding 'info' with no dummy arguments must have NOPASS attribute
      procedure :: info => real_info
                   ^^^^

With the fix of #55826 , it now produces

error: Semantic errors in 55825.f
./55825.f:8:18: error: Procedure binding 'info' with no dummy arguments must have NOPASS attribute
      procedure :: info => real_info
                   ^^^^
./55825.f:21:24: error: Reference to whole rank-1 component 't1' of rank-1 array of derived type is not allowed
    call sub1(t%t3%t2%t1%info)
                         ^^^^

Both error messages look correct to me, although the new issue #59967 may add one more error message to both #55826 and this one. For reference, if I had

module m
  type dt
   contains
    procedure :: foo => real_foo
  end type
contains
    subroutine real_foo(this)
      class(dt) :: this
    end
end

program main
use m
  interface
    subroutine sub1(arg)
    import
    class(dt) :: arg
    end subroutine
  end interface
  type(dt) :: t1
  call sub1(t1%foo)
end

It produces:

error: Semantic errors in t1.f
./t1.f:21:13: error: Actual argument 't1%foo' associated with dummy argument 'arg=' is not a variable or typed expression
    call sub1(t1%foo)
              ^^^^^^

DanielCChen avatar Jan 12 '23 16:01 DanielCChen

@DanielCChen Thanks for the work. I confirm the semantic check has been supported for the test case in this issue.

PeixinQiao avatar Jan 19 '23 06:01 PeixinQiao