From 4da5be5562b65570db85163a17902eb0605ac9eb Mon Sep 17 00:00:00 2001 From: Krzysztof Parzyszek Date: Wed, 28 May 2025 15:08:20 -0500 Subject: [PATCH] [flang][OpenMP] Treat ClassType as BoxType in COPYPRIVATE This fixes the second problem reported in https://github.com/llvm/llvm-project/issues/141481 --- flang/lib/Lower/OpenMP/ClauseProcessor.cpp | 3 +++ flang/test/Lower/OpenMP/copyprivate4.f90 | 18 ++++++++++++++++++ 2 files changed, 21 insertions(+) create mode 100644 flang/test/Lower/OpenMP/copyprivate4.f90 diff --git a/flang/lib/Lower/OpenMP/ClauseProcessor.cpp b/flang/lib/Lower/OpenMP/ClauseProcessor.cpp index 885871698c946..afbc77d48cb53 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