[flang-commits] [flang] [flang] Fix TRANSFER into derived type with tail padding zeroing pad bytes (PR #223814)
via flang-commits
flang-commits at lists.llvm.org
Wed Sep 16 20:37:06 PDT 2026
================
@@ -151,3 +151,24 @@ subroutine trans_test_alloc_source(store, src)
real, allocatable :: src
store = transfer(src, store)
end subroutine
+
+ ! TRANSFER into a SEQUENCE derived type with tail padding: the assignment back
+ ! to the derived-type variable must use fir.copy (full storage size including
+ ! tail padding) rather than a field-by-field copy that silently drops padding.
+ subroutine trans_test_seq_tail_pad(raw, x)
+ ! CHECK-LABEL: func @_QPtrans_test_seq_tail_pad(
+ ! CHECK: fir.call @_FortranATransfer(
----------------
MattPD wrote:
This test passes with the parent's compiler. `-emit-hlfir` stops before `convert-hlfir-to-fir`, and the patch only changes `convert-hlfir-to-fir`, so the checked `fir.call @_FortranATransfer` and `hlfir.assign` lines are identical on the parent and on this branch. I ran the file's RUN line with the parent's compiler and FileCheck accepted the output. The subroutine's introductory comment mentions `fir.copy`, but `-emit-hlfir` output never contains it. A `bbc -emit-fir` RUN line checking for `fir.copy {{.*}} no_overlap` on the `sequence{a:i32,b:i8}` type fails on the parent and passes on this branch. `flang/test/Lower/OpenACC/acc-firstprivate-derived.f90` has a RUN line of this form.
https://github.com/llvm/llvm-project/pull/223814
More information about the flang-commits
mailing list