File tree Expand file tree Collapse file tree 2 files changed +24
-1
lines changed Expand file tree Collapse file tree 2 files changed +24
-1
lines changed Original file line number Diff line number Diff line change @@ -833,7 +833,11 @@ class FirConverter : public Fortran::lower::AbstractConverter {
833833 if_builder.end ();
834834 },
835835 [&](const auto &) -> void {
836- if (skipDefaultInit)
836+ // Always initialize allocatable component descriptor, even when the
837+ // value is later copied from the host (e.g. firstprivate) because the
838+ // assignment from the host to the copy will fail if the component
839+ // descriptors are not initialized.
840+ if (skipDefaultInit && !hlfir::mayHaveAllocatableComponent (hSymType))
837841 return ;
838842 // Initialize local/private derived types with default
839843 // initialization (Fortran 2023 section 11.1.7.5 and OpenMP 5.2
Original file line number Diff line number Diff line change 1+ ! Test delayed privatization for derived types with allocatable components.
2+ ! RUN: %flang_fc1 -emit-hlfir -fopenmp -o - %s | FileCheck %s
3+
4+ subroutine firstprivate_alloc_comp
5+ type t1
6+ integer , allocatable :: c(:)
7+ end type
8+ type (t1) :: x
9+ ! $omp parallel firstprivate(x)
10+ print * , allocated (x% c)
11+ ! $omp end parallel
12+ end
13+
14+ call firstprivate_alloc_comp()
15+ end
16+ ! CHECK-LABEL: omp.private {type = firstprivate} @_QFfirstprivate_alloc_compEx_firstprivate_ref_rec__QFfirstprivate_alloc_compTt1 : !fir.ref<!fir.type<_QFfirstprivate_alloc_compTt1{c:!fir.box<!fir.heap<!fir.array<?xi32>>>}>> alloc {
17+ ! CHECK: fir.call @_FortranAInitialize(
18+ ! CHECK: } copy {
19+ ! ...
You can’t perform that action at this time.
0 commit comments