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

[Flang] Compilation error when an array declared as unlimited polymorphic is used in where construct

Open ohno-fj opened this issue 1 year ago • 3 comments

Version of flang : 21.0.0(b2b3cb5f76f15d38e67f70124d275a5696bfdb83)/AArch64

When arrays declared as unlimited polymorphic are used in where construct, a compilation error occurs.
When where construct is removed, the compilation succeeds.

The following are the test program, Flang, Gfortran and ifx compilation/execution result.

sngg322r_2.f90:

module m1
  type x
  end type x
  logical,parameter::t=.true.,f=.false.
  logical::mask(3)=[t,f,t]
end module m1

subroutine s1
  use m1
  class(*),allocatable::v(:),u(:)
  allocate(x::v(3))
  allocate(x::u(3))
  where(mask)
     u=v
  end where
end subroutine s1

program main
  call s1
  print *,'pass'
end program main
$ flang sngg322r_2.f90
error: loc("/work/home/ohno/CT/test/fort/tp/reproducerJ/FFE_2022_PH19703_23/sngg322r_2.f90":14:6): 'fir.store' op operand #1 must be any reference, but got '!fir.class<none>'
error: Lowering to LLVM IR failed
error: loc("/work/home/ohno/CT/test/fort/tp/reproducerJ/FFE_2022_PH19703_23/sngg322r_2.f90":1:1): LLVM Translation failed for operation: fir.global
error: failed to create the LLVM module
$
$ gfortran sngg322r_2.f90; ./a.out
 pass
$
$ ifx sngg322r_2.f90; ./a.out
 pass
$

ohno-fj avatar Mar 31 '25 01:03 ohno-fj

@llvm/issue-subscribers-flang-ir

Author: None (ohno-fj)

``` Version of flang : 21.0.0(b2b3cb5f76f15d38e67f70124d275a5696bfdb83)/AArch64 ``` When arrays declared as `unlimited polymorphic` are used in `where construct`, a compilation error occurs. When `where construct` is removed, the compilation succeeds.

The following are the test program, Flang, Gfortran and ifx compilation/execution result.

sngg322r_2.f90:

module m1
  type x
  end type x
  logical,parameter::t=.true.,f=.false.
  logical::mask(3)=[t,f,t]
end module m1

subroutine s1
  use m1
  class(*),allocatable::v(:),u(:)
  allocate(x::v(3))
  allocate(x::u(3))
  where(mask)
     u=v
  end where
end subroutine s1

program main
  call s1
  print *,'pass'
end program main
$ flang sngg322r_2.f90
error: loc("/work/home/ohno/CT/test/fort/tp/reproducerJ/FFE_2022_PH19703_23/sngg322r_2.f90":14:6): 'fir.store' op operand #<!-- -->1 must be any reference, but got '!fir.class&lt;none&gt;'
error: Lowering to LLVM IR failed
error: loc("/work/home/ohno/CT/test/fort/tp/reproducerJ/FFE_2022_PH19703_23/sngg322r_2.f90":1:1): LLVM Translation failed for operation: fir.global
error: failed to create the LLVM module
$
$ gfortran sngg322r_2.f90; ./a.out
 pass
$
$ ifx sngg322r_2.f90; ./a.out
 pass
$

llvmbot avatar Mar 31 '25 02:03 llvmbot

Reassigning this to @klausler per discussion in PR #159624

ceseo avatar Sep 22 '25 20:09 ceseo

@llvm/issue-subscribers-flang-frontend

Author: None (ohno-fj)

``` Version of flang : 21.0.0(b2b3cb5f76f15d38e67f70124d275a5696bfdb83)/AArch64 ``` When arrays declared as `unlimited polymorphic` are used in `where construct`, a compilation error occurs. When `where construct` is removed, the compilation succeeds.

The following are the test program, Flang, Gfortran and ifx compilation/execution result.

sngg322r_2.f90:

module m1
  type x
  end type x
  logical,parameter::t=.true.,f=.false.
  logical::mask(3)=[t,f,t]
end module m1

subroutine s1
  use m1
  class(*),allocatable::v(:),u(:)
  allocate(x::v(3))
  allocate(x::u(3))
  where(mask)
     u=v
  end where
end subroutine s1

program main
  call s1
  print *,'pass'
end program main
$ flang sngg322r_2.f90
error: loc("/work/home/ohno/CT/test/fort/tp/reproducerJ/FFE_2022_PH19703_23/sngg322r_2.f90":14:6): 'fir.store' op operand #<!-- -->1 must be any reference, but got '!fir.class&lt;none&gt;'
error: Lowering to LLVM IR failed
error: loc("/work/home/ohno/CT/test/fort/tp/reproducerJ/FFE_2022_PH19703_23/sngg322r_2.f90":1:1): LLVM Translation failed for operation: fir.global
error: failed to create the LLVM module
$
$ gfortran sngg322r_2.f90; ./a.out
 pass
$
$ ifx sngg322r_2.f90; ./a.out
 pass
$

llvmbot avatar Sep 30 '25 18:09 llvmbot