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

Actual argument 'transfer(msg,dat)' associated with dummy argument 'array=' is not a variable or typed expression

Open rikigigi opened this issue 6 years ago • 3 comments

Bugzilla Link 47548
Version trunk
OS Linux
CC @jeanPerier,@kiranktp,@rikigigi,@sscalpone,@tskeith

Extended Description

this compiles under gfortran and ifort, but not flang

[rbertoss@mugon bug_report]$ cat bug.f90 MODULE test IMPLICIT NONE INTERFACE FUNCTION fletcher32( dat, dat_size ) BIND(C,name="fletcher32") RESULT(t) USE ISO_C_BINDING integer(kind=c_int16_t) :: dat(*) integer(kind=c_int32_t) :: dat_size integer(kind=c_int32_t) :: t END FUNCTION fletcher32 END INTERFACE CONTAINS SUBROUTINE fletcher32_i1(msg, cksum) !!this compiles IMPLICIT NONE INTEGER, INTENT(IN) :: msg INTEGER, INTENT(OUT) :: cksum INTEGER(2) :: dat(1)

     cksum = fletcher32(transfer(msg,dat),size(transfer(msg,dat)))

  END SUBROUTINE fletcher32_i1
  SUBROUTINE fletcher32_iv(msg, cksum) !! this does not
     IMPLICIT NONE
     INTEGER, INTENT(IN) :: msg(:)  !!!!<<<==== the only difference wrt previous subroutine
     INTEGER, INTENT(OUT) :: cksum
     INTEGER(2) :: dat(1)

     cksum = fletcher32(transfer(msg,dat),size(transfer(msg,dat)))

  END SUBROUTINE fletcher32_iv

END MODULE [rbertoss@mugon bug_report]$ /scratch/rbertoss/llvm/llvm-project/OBJ_ROOT_2/bin/flang bug.f90 -c bug.f90:27:18: error: Actual argument 'transfer(msg,dat)' associated with dummy argument 'dat=' is not a variable or typed expression cksum = fletcher32(transfer(msg,dat),size(transfer(msg,dat))) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ bug.f90:27:47: error: Actual argument 'transfer(msg,dat)' associated with dummy argument 'array=' is not a variable or typed expression cksum = fletcher32(transfer(msg,dat),size(transfer(msg,dat))) ^^^^^^^^^^^^^^^^^^^^^^^ /scratch/rbertoss/llvm/llvm-project/OBJ_ROOT_2/bin/f18: semantic errors in bug.f90

rikigigi avatar Sep 16 '20 13:09 rikigigi

On other example that shows the problem:

[rbertoss@mugon bug_report]$ cat bug1_.f90 MODULE bug IMPLICIT NONE CONTAINS SUBROUTINE whatever(p) real, intent(in) :: p(:) write (,) p*2 end subroutine SUBROUTINE test(inv,outv) IMPLICIT NONE INTEGER, INTENT(IN) :: inv(:) ! an array REAL, INTENT(OUT) :: outv(:) REAL :: dat(1)

     outv = transfer(inv,dat)
     call whatever(outv) ! ok 
     call whatever(transfer(inv,dat)) ! compiler error

  END SUBROUTINE test
 SUBROUTINE test2(inv,outv)
     IMPLICIT NONE
     INTEGER, INTENT(IN) :: inv ! not an array
     REAL, INTENT(OUT) :: outv(:)
     REAL :: dat(1)

     outv = transfer(inv,dat)
     call whatever(outv)  ! ok
     call whatever(transfer(inv,dat)) ! ok

  END SUBROUTINE test2

END MODULE

[rbertoss@mugon bug_report]$ /scratch/rbertoss/llvm/llvm-project/OBJ_ROOT_2/bin/f18 -module-suffix .f18.mod -intrinsic-module-directory /scratch/rbertoss/llvm/llvm-project/OBJ_ROOT_2/tools/flang/include/flang bug1_.f90 -c bug1_.f90:16:10: error: Actual argument 'transfer(inv,dat)' associated with dummy argument 'p=' is not a variable or typed expression call whatever(transfer(inv,dat)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /scratch/rbertoss/llvm/llvm-project/OBJ_ROOT_2/bin/f18: semantic errors in bug1_.f90 [rbertoss@mugon bug_report]$

rikigigi avatar Oct 15 '20 07:10 rikigigi

This one appears to have been fixed, I cannot reproduce it with 0f304ef01702 from today (Ubuntu 21.10, x86, clang 13). Is anybody aware of who fixed it and when?

ekieri avatar Apr 16 '22 08:04 ekieri

Closing, as it appears to have been fixed. Please do not hesitate to reopen if the problem persists for you.

ekieri avatar May 07 '22 19:05 ekieri