[flang-commits] [flang] 4811c67 - [flang][OpenMP] Treat ClassType as BoxType in COPYPRIVATE (#141844)
via flang-commits
flang-commits at lists.llvm.org
Thu May 29 12:32:52 PDT 2025
Author: Krzysztof Parzyszek
Date: 2025-05-29T14:32:49-05:00
New Revision: 4811c67d62b840a7f5d3320de0b15ba96e27d2e4
URL: https://github.com/llvm/llvm-project/commit/4811c67d62b840a7f5d3320de0b15ba96e27d2e4
DIFF: https://github.com/llvm/llvm-project/commit/4811c67d62b840a7f5d3320de0b15ba96e27d2e4.diff
LOG: [flang][OpenMP] Treat ClassType as BoxType in COPYPRIVATE (#141844)
This fixes the second problem reported in
https://github.com/llvm/llvm-project/issues/141481
Added:
flang/test/Lower/OpenMP/copyprivate4.f90
Modified:
flang/lib/Lower/OpenMP/ClauseProcessor.cpp
Removed:
################################################################################
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<fir::BoxType>(ty)) {
inBox = true;
typeScan(bty.getEleTy());
+ } else if (auto cty = mlir::dyn_cast<fir::ClassType>(ty)) {
+ inBox = true;
+ typeScan(cty.getEleTy());
} else if (auto cty = mlir::dyn_cast<fir::CharacterType>(ty)) {
charLen = cty.getLen();
} else if (auto hty = mlir::dyn_cast<fir::HeapType>(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<!fir.class<!fir.ptr<!fir.type<_QFf01Tt>>>>) {
+!CHECK: omp.terminator
+!CHECK: }
+
+subroutine f01
+ type t
+ end type
+ class(t), pointer :: tt
+
+!$omp single copyprivate(tt)
+!$omp end single
+end
More information about the flang-commits
mailing list