<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/218760>218760</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[Flang][OpenMP] DO CONCURRENT device conversion aborts on arrays with nested derived-type components
</td>
</tr>
<tr>
<th>Labels</th>
<td>
flang,
crash-on-valid,
flang:fir-hlfir,
flang:openmp
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
MattPD
</td>
</tr>
</table>
<pre>
### Description
Flang aborts while converting a valid `DO CONCURRENT` loop to OpenMP device constructs when an array element contains a component whose type is another derived type.
The conversion reaches the following `TODO` while inspecting the nested derived-type component:
https://github.com/llvm/llvm-project/blob/6120eb5267a8643dd399f8858b6c92f23a846551/flang/lib/Optimizer/OpenMP/DoConcurrentConversion.cpp#L599-L627
### Reproducer
```fortran
program nested_derived
implicit none
type :: inner_t
integer :: x
end type
type :: outer_t
type(inner_t) :: member
end type
type(outer_t) :: a(4)
integer :: i
do concurrent (i = 1:4)
a(i)%member%x = i
end do
if (any(a%member%x /= [1, 2, 3, 4])) error stop 1
end program
```
### Command
```console
flang -c -fopenmp -fdo-concurrent-to-openmp=device \
--offload-arch=gfx908 nested-derived.f90
```
### Result
```text
error: loc("nested-derived.f90":12:20): ../llvm-project/flang/lib/Optimizer/OpenMP/DoConcurrentConversion.cpp:615: not yet implemented: Nested record types are not supported yet.
LLVM ERROR: aborting
```
The reproducer uses no allocatable or pointer components and no procedure calls.
The abort happens at compile time, so reproducing it needs no GPU. The same reproducer compiles successfully with `-fdo-concurrent-to-openmp=host`.
### Expected behavior
Flang should map nested derived-type components or emit an unsupported-feature diagnostic. The compiler should not abort with `LLVM ERROR`.
### Version
The failure was reproduced with Flang 24.0.0git at `00890d9f885989008a8cb5cf5f5335f6f385dbd4` while compiling for AMDGPU. The permalinks above point at upstream commit `6120eb5267a8643dd399f8858b6c92f23a846551`, which still contains the same `TODO`.
### Motivation
The portability study [Portability of Fortran's `do concurrent` on GPUs II](https://arxiv.org/abs/2608.20586) names MAS as its next target beyond POT3D. MAS is a larger application that uses derived types. The paper does not establish whether MAS uses nested derived types. The minimal case still exposes a general device-conversion gap.
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJykVt1u2zoSfhr6ZiCDpixZuvCFG9eLAzRNkO05twUljSzuUqRAUk68T78YSv5JWgS7OECg1iTn75uZb0Z6r44GccuyLyzbL-QYOuu2jzKE5_2iss15y0Q6_cEefe3UEJQ1jO8Y3x20NEeQlXXBw2unNEJtzQldUHQOJ6lVAyzn-yd4ePr-8OfLy9fvP1jOQVs7QLDwNKB5fIYGT6qOwj64sY7a0IA0IJ2TZ0CNPZpAD4JUxoOE2vaDNXT42lmPEM4DgvIgjQ0dOmjQqRM28Xw5ufuju_jnlTXgUNYdeggdQmu1tq_kNcv5j6f9Ezk5RaSMH7COEdFLgz5gc1GfRLNXX1i6m0x1IQyefokDE4ejCt1YLWvbM3HQ-nT5Jxmc_RfWgYlDpW3FxCFfCY5VJvKNLPJ12jRpWbZFkRVVXpeiFaks1nmWrZg4tAQ-KVIk-DQE1av_oIv_J1CZOOztgzX16Bya8HANfFkPAxPpt6wsk2-52Ewe39L8goOzzVijm29yPv211gUnKfeDs0cn-xmMnzMYjO8AVD9oVasAxhqcFMCUHIIj3YEyBt3PEM8BlAl4RHe5fIvHaKa8_U7cjuEiHp-I4qJQlJc3PfZV9P73qpgoLlpuMpKJYs1EOQXx3it1kW4sFdCMKJBtYOkeVizdXWUhqlL0U2SzJyJ7iw_V1afGXnSqlhRJc6bvBxFxICmWfVkx8QCCPil91izbRwMloHPWgQ92gBXjO9I9Z-c-dR9z_GD7XprmQ4Kp_6wmrGJxQVJD0toBTT9A0jY2uQWfBJtMNyzdz-3LsocYUZLYttVWNol0dcfS_bF9K3kxV0syV8uyLflnLr6gH3X44GHANzqKQVNmtK2ZKJgQv9EtBEt3K_oITmClO1guf-28v9dH6S5fZaTa2AB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