Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion flang/lib/Lower/OpenMP/DataSharingProcessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,8 @@ void DataSharingProcessor::cloneSymbol(const semantics::Symbol *sym) {
assert(sb);
mlir::Value addr = sb.getAddr();
assert(addr);
return hlfir::mayHaveAllocatableComponent(addr.getType());
return !fir::isPointerType(addr.getType()) &&
hlfir::mayHaveAllocatableComponent(addr.getType());
};

if (needInitClone()) {
Expand Down
4 changes: 4 additions & 0 deletions flang/runtime/derived.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,10 @@ RT_API_ATTRS int InitializeClone(const Descriptor &clone,
std::size_t elements{orig.Elements()};
int stat{StatOk};

// Skip pointers and unallocated variables.
if (orig.IsPointer() || !orig.IsAllocated()) {
return stat;
}
// Initialize each data component.
std::size_t components{componentDesc.Elements()};
for (std::size_t i{0}; i < components; ++i) {
Expand Down
11 changes: 11 additions & 0 deletions flang/test/Lower/OpenMP/derived-type-allocatable.f90
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ module m1

contains

!CHECK-LABEL: omp.private {type = private} @_QMm1Ftest_pointer
!CHECK-NOT: fir.call @_FortranAInitializeClone
!CHECK: omp.yield

!CHECK-LABEL: omp.private {type = private} @_QMm1Ftest_nested
!CHECK: fir.call @_FortranAInitializeClone
!CHECK-NEXT: omp.yield
Expand Down Expand Up @@ -91,4 +95,11 @@ subroutine test_nested()
!$omp parallel private(d2)
!$omp end parallel
end subroutine

subroutine test_pointer()
type(x), pointer :: ptr

!$omp parallel private(ptr)
!$omp end parallel
end subroutine
end module
Loading