program flattening_test
use iso_fortran_env, only : int32
implicit none
type mytype
integer(int32) :: k
end type mytype
class(mytype), allocatable :: multidim_array(:,:)
integer(int32), parameter :: num = 4
integer(int32) :: i
allocate(mytype :: multidim_array(num,num))
call reinterpret_1d(multidim_array,num*num)
contains
subroutine reinterpret_1d(array, n)
integer(int32), intent(in) :: n
type(mytype), intent(inout) :: array(n)
integer(int32):: j
do j = 1, n
array(j)%k = j
enddo
end subroutine reinterpret_1d
end program flattening_test
Error:
>> flang-new contained_subroutine_flatten.f90
error: loc("/home/bcornill/Reproducers/SWDEV/temp/contained_subroutine_flatten.f90":14:3): 'fir.rebox' op result type and shape operand ranks must match
error: verification of lowering to FIR failed
Changing either class(mytype), allocatable :: multidim_array(:,:) to type(mytype), allocatable :: multidim_array(:,:) or type(mytype), intent(inout) :: array(n) to class(mytype), intent(inout) :: array(n) resolves the error.
Reproducer: (contained_subroutine_flatten.f90)
```
program flattening_test
use iso_fortran_env, only : int32
implicit none
type mytype
integer(int32) :: k
end type mytype
class(mytype), allocatable :: multidim_array(:,:)
integer(int32), parameter :: num = 4
integer(int32) :: i
allocate(mytype :: multidim_array(num,num))
call reinterpret_1d(multidim_array,num*num)
contains
subroutine reinterpret_1d(array, n)
integer(int32), intent(in) :: n
type(mytype), intent(inout) :: array(n)
integer(int32):: j
do j = 1, n
array(j)%k = j
enddo
end subroutine reinterpret_1d
end program flattening_test
```
Error:
```
>> flang-new contained_subroutine_flatten.f90
error: loc("/home/bcornill/Reproducers/SWDEV/temp/contained_subroutine_flatten.f90":14:3): 'fir.rebox' op result type and shape operand ranks must match
error: verification of lowering to FIR failed
```
Changing either `class(mytype), allocatable :: multidim_array(:,:)` to `type(mytype), allocatable :: multidim_array(:,:)` or `type(mytype), intent(inout) :: array(n)` to `class(mytype), intent(inout) :: array(n)` resolves the error.
Reproducer: (contained_subroutine_flatten.f90)
Error:
Changing either
class(mytype), allocatable :: multidim_array(:,:)
totype(mytype), allocatable :: multidim_array(:,:)
ortype(mytype), intent(inout) :: array(n)
toclass(mytype), intent(inout) :: array(n)
resolves the error.