diff --git a/flang/include/flang/Optimizer/Builder/DirectivesCommon.h b/flang/include/flang/Optimizer/Builder/DirectivesCommon.h index 3f30c761acb4..f71a2ccd07bf 100644 --- a/flang/include/flang/Optimizer/Builder/DirectivesCommon.h +++ b/flang/include/flang/Optimizer/Builder/DirectivesCommon.h @@ -75,9 +75,6 @@ inline AddrAndBoundsInfo getDataOperandBaseAddr(fir::FirOpBuilder &builder, if (auto boxTy = mlir::dyn_cast( fir::unwrapRefType(symAddr.getType()))) { - if (mlir::isa(boxTy.getEleTy())) - TODO(loc, "derived type"); - // In case of a box reference, load it here to get the box value. // This is preferrable because then the same box value can then be used for // all address/dimension retrievals. For Fortran optional though, leave diff --git a/flang/lib/Optimizer/OpenACC/RegisterOpenACCExtensions.cpp b/flang/lib/Optimizer/OpenACC/RegisterOpenACCExtensions.cpp index 16115c7cb6e5..5f174ad4b40f 100644 --- a/flang/lib/Optimizer/OpenACC/RegisterOpenACCExtensions.cpp +++ b/flang/lib/Optimizer/OpenACC/RegisterOpenACCExtensions.cpp @@ -22,6 +22,8 @@ void registerOpenACCExtensions(mlir::DialectRegistry ®istry) { fir::SequenceType::attachInterface>( *ctx); fir::BoxType::attachInterface>(*ctx); + fir::ClassType::attachInterface>( + *ctx); fir::ReferenceType::attachInterface< OpenACCPointerLikeModel>(*ctx); diff --git a/flang/test/Lower/OpenACC/acc-enter-data.f90 b/flang/test/Lower/OpenACC/acc-enter-data.f90 index f7396660a6d3..2718c96a563f 100644 --- a/flang/test/Lower/OpenACC/acc-enter-data.f90 +++ b/flang/test/Lower/OpenACC/acc-enter-data.f90 @@ -2,6 +2,14 @@ ! RUN: bbc -fopenacc -emit-hlfir %s -o - | FileCheck %s +module mod1 + implicit none + type :: derived + real :: m + contains + end type derived +end module mod1 + subroutine acc_enter_data integer :: async = 1 real, dimension(10, 10) :: a, b, c @@ -651,3 +659,15 @@ subroutine acc_enter_data_single_array_element() !CHECK: acc.enter_data dataOperands(%[[CREATE]] : !fir.heap>) end subroutine + +subroutine test_class(a) + use mod1 + class(derived) :: a + !$acc enter data copyin(a) +end subroutine + +! CHECK-LABEL: func.func @_QPtest_class( +! CHECK-SAME: %[[ARG0:.*]]: !fir.class> {fir.bindc_name = "a"}) { +! CHECK: %[[DECL_ARG0:.*]]:2 = hlfir.declare %[[ARG0]] dummy_scope %0 {uniq_name = "_QFtest_classEa"} : (!fir.class>, !fir.dscope) -> (!fir.class>, !fir.class>) +! CHECK: %[[COPYIN:.*]] = acc.copyin var(%[[DECL_ARG0]]#0 : !fir.class>) -> !fir.class> {name = "a", structured = false} +! CHECK: acc.enter_data dataOperands(%[[COPYIN]] : !fir.class>)