[flang-commits] [flang] [llvm] [Flang][OpenMP] Avoid aborting on nested derived types in DO CONCURRENT device conversion (PR #218963)

via flang-commits flang-commits at lists.llvm.org
Thu Sep 3 16:47:11 PDT 2026


agozillon wrote:

> Thanks @agozillon!
> 
No problem.

> Regarding `fir::isRecordWithAllocatableMember`: we actually explored that during the first review round, but as @TIFitis noted on #220099, `fir::isRecordWithAllocatableMember` doesn't inspect components that are arrays of derived types, e.g. `type(inner) :: child(2)`, which are lowered as a `fir::SequenceType`. In that case it returns `false` and misses the nested allocatable. That's why `recordHasAllocatableMember` unwraps the element type with `fir::getFortranElementType(fieldType)` before recursing.
> 

That is true, I thought it may be as simple as `fir::isRecordWithAllocatableMember(fir::unwrapSequenceType(type))` but it seems the function isRecordWithAllocatableMember doesn't quite handle the sequence type internally. However, I would recommend altering fir::isRecordWithAllocatableMember to support the sequence unwrapping as it does seem intended to handle nested record types, it just seems the edge case of a sequence/array of records has been missed just like here :-) As it seems like it would be better to have one re-useable utility function as opposed to an implementation specific to this pass, as it's utilised elsewhere for similar reasons.

> I've added your offload test from #220099 (`offload/test/offloading/fortran/do-concurrent-to-omp-nested-derived-type.f90`) to this PR for the additional coverage—thank you for putting that together!

Thank you for including it!

https://github.com/llvm/llvm-project/pull/218963


More information about the flang-commits mailing list