Skip to content

Commit 4811c67

Browse files
authored
[flang][OpenMP] Treat ClassType as BoxType in COPYPRIVATE (#141844)
This fixes the second problem reported in #141481
1 parent 2a22e79 commit 4811c67

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

flang/lib/Lower/OpenMP/ClauseProcessor.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -743,6 +743,9 @@ void TypeInfo::typeScan(mlir::Type ty) {
743743
} else if (auto bty = mlir::dyn_cast<fir::BoxType>(ty)) {
744744
inBox = true;
745745
typeScan(bty.getEleTy());
746+
} else if (auto cty = mlir::dyn_cast<fir::ClassType>(ty)) {
747+
inBox = true;
748+
typeScan(cty.getEleTy());
746749
} else if (auto cty = mlir::dyn_cast<fir::CharacterType>(ty)) {
747750
charLen = cty.getLen();
748751
} else if (auto hty = mlir::dyn_cast<fir::HeapType>(ty)) {
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
!RUN: %flang_fc1 -emit-hlfir -fopenmp -o - %s 2>&1 | FileCheck %s
2+
3+
!The second testcase from https://github.com/llvm/llvm-project/issues/141481
4+
5+
!Check that we don't crash on this.
6+
7+
!CHECK: omp.single copyprivate(%6#0 -> @_copy_class_ptr_rec__QFf01Tt : !fir.ref<!fir.class<!fir.ptr<!fir.type<_QFf01Tt>>>>) {
8+
!CHECK: omp.terminator
9+
!CHECK: }
10+
11+
subroutine f01
12+
type t
13+
end type
14+
class(t), pointer :: tt
15+
16+
!$omp single copyprivate(tt)
17+
!$omp end single
18+
end

0 commit comments

Comments
 (0)