diff --git a/flang/lib/Lower/OpenMP/ClauseProcessor.cpp b/flang/lib/Lower/OpenMP/ClauseProcessor.cpp index ebdda9885d5c2..a1fff6c5b7d90 100644 --- a/flang/lib/Lower/OpenMP/ClauseProcessor.cpp +++ b/flang/lib/Lower/OpenMP/ClauseProcessor.cpp @@ -743,6 +743,9 @@ void TypeInfo::typeScan(mlir::Type ty) { } else if (auto bty = mlir::dyn_cast(ty)) { inBox = true; typeScan(bty.getEleTy()); + } else if (auto cty = mlir::dyn_cast(ty)) { + inBox = true; + typeScan(cty.getEleTy()); } else if (auto cty = mlir::dyn_cast(ty)) { charLen = cty.getLen(); } else if (auto hty = mlir::dyn_cast(ty)) { diff --git a/flang/test/Lower/OpenMP/copyprivate4.f90 b/flang/test/Lower/OpenMP/copyprivate4.f90 new file mode 100644 index 0000000000000..02fdbc71edc59 --- /dev/null +++ b/flang/test/Lower/OpenMP/copyprivate4.f90 @@ -0,0 +1,18 @@ +!RUN: %flang_fc1 -emit-hlfir -fopenmp -o - %s 2>&1 | FileCheck %s + +!The second testcase from https://github.com/llvm/llvm-project/issues/141481 + +!Check that we don't crash on this. + +!CHECK: omp.single copyprivate(%6#0 -> @_copy_class_ptr_rec__QFf01Tt : !fir.ref>>>) { +!CHECK: omp.terminator +!CHECK: } + +subroutine f01 + type t + end type + class(t), pointer :: tt + +!$omp single copyprivate(tt) +!$omp end single +end