Skip to content

[flang][OpenMP] Treat ClassType as BoxType in COPYPRIVATE #141844

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 29, 2025
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: 3 additions & 0 deletions flang/lib/Lower/OpenMP/ClauseProcessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down
18 changes: 18 additions & 0 deletions flang/test/Lower/OpenMP/copyprivate4.f90
Original file line number Diff line number Diff line change
@@ -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