diff --git a/flang/lib/Lower/OpenACC.cpp b/flang/lib/Lower/OpenACC.cpp index 7ab6468320ee2..c9fe64e0eabc2 100644 --- a/flang/lib/Lower/OpenACC.cpp +++ b/flang/lib/Lower/OpenACC.cpp @@ -2458,6 +2458,13 @@ genDeclareInFunction(Fortran::lower::AbstractConverter &converter, /*structured=*/true, /*setDeclareAttr=*/true); copyoutEntryOperands.append(dataClauseOperands.begin() + crtDataStart, dataClauseOperands.end()); + } else if (const auto *devicePtrClause = + std::get_if( + &clause.u)) { + genDataOperandOperations( + devicePtrClause->v, converter, semanticsContext, stmtCtx, + dataClauseOperands, mlir::acc::DataClause::acc_deviceptr, + /*structured=*/true); } else { mlir::Location clauseLocation = converter.genLocation(clause.source); TODO(clauseLocation, "clause on declare directive"); diff --git a/flang/test/Lower/OpenACC/acc-declare.f90 b/flang/test/Lower/OpenACC/acc-declare.f90 index 971b0a14613e9..bf873971a4050 100644 --- a/flang/test/Lower/OpenACC/acc-declare.f90 +++ b/flang/test/Lower/OpenACC/acc-declare.f90 @@ -173,4 +173,20 @@ subroutine acc_declare_copyout() ! CHECK: acc.copyout accPtr(%[[CREATE]] : !fir.ref>) bounds(%{{.*}}) to varPtr(%[[A]] : !fir.ref>) {name = "a"} ! CHECK: return + subroutine acc_declare_deviceptr(a) + integer :: a(100), i + !$acc declare deviceptr(a) + + do i = 1, 100 + a(i) = i + end do + end subroutine + +! CHECK-LABEL: func.func @_QMacc_declarePacc_declare_deviceptr( +! CHECK-SAME: %[[ARG0:.*]]: !fir.ref> {fir.bindc_name = "a"}) { +! CHECK: %[[DEVICEPTR:.*]] = acc.deviceptr varPtr(%[[ARG0]] : !fir.ref>) bounds(%{{.*}}) -> !fir.ref> {name = "a"} +! CHECK: acc.declare_enter dataOperands(%[[DEVICEPTR]] : !fir.ref>) +! CHECK: %{{.*}}:2 = fir.do_loop %{{.*}} = %{{.*}} to %{{.*}} step %{{.*}} iter_args(%arg{{.*}} = %{{.*}}) -> (index, i32) +! CHECK-NOT: acc.declare_exit + end module