Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
ohno-fj opened this issue Mar 31, 2025 · 1 comment
Labels

Comments

@ohno-fj
Copy link

ohno-fj commented Mar 31, 2025

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 ohno-fj added the flang Flang issues not falling into any other category label Mar 31, 2025
@EugeneZelenko EugeneZelenko added flang:ir and removed flang Flang issues not falling into any other category labels Mar 31, 2025
@llvmbot
Copy link
Member

llvmbot commented Mar 31, 2025

@llvm/issue-subscribers-flang-ir

Author: None (ohno-fj)

``` Version of flang : 21.0.0(b2b3cb5)/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
$

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

3 participants