@@ -307,6 +307,25 @@ template <bool IsCUFKernelDo> class DeviceContextChecker {
307307 WarnOnIoStmt (source);
308308 }
309309 }
310+ template <typename A>
311+ void ErrorIfHostSymbol (const A &expr, const parser::CharBlock &source) {
312+ for (const Symbol &sym : CollectCudaSymbols (expr)) {
313+ if (const auto *details =
314+ sym.GetUltimate ().detailsIf <semantics::ObjectEntityDetails>()) {
315+ if (details->IsArray () &&
316+ (!details->cudaDataAttr () ||
317+ (details->cudaDataAttr () &&
318+ *details->cudaDataAttr () != common::CUDADataAttr::Device &&
319+ *details->cudaDataAttr () != common::CUDADataAttr::Managed &&
320+ *details->cudaDataAttr () !=
321+ common::CUDADataAttr::Unified))) {
322+ context_.Say (source,
323+ " Host array '%s' cannot be present in CUF kernel" _err_en_US,
324+ sym.name ());
325+ }
326+ }
327+ }
328+ }
310329 void Check (const parser::ActionStmt &stmt, const parser::CharBlock &source) {
311330 common::visit (
312331 common::visitors{
@@ -349,6 +368,19 @@ template <bool IsCUFKernelDo> class DeviceContextChecker {
349368 [&](const common::Indirection<parser::IfStmt> &x) {
350369 Check (x.value ());
351370 },
371+ [&](const common::Indirection<parser::AssignmentStmt> &x) {
372+ if (IsCUFKernelDo) {
373+ const evaluate::Assignment *assign{
374+ semantics::GetAssignment (x.value ())};
375+ if (assign) {
376+ ErrorIfHostSymbol (assign->lhs , source);
377+ ErrorIfHostSymbol (assign->rhs , source);
378+ }
379+ }
380+ if (auto msg{ActionStmtChecker<IsCUFKernelDo>::WhyNotOk (x)}) {
381+ context_.Say (source, std::move (*msg));
382+ }
383+ },
352384 [&](const auto &x) {
353385 if (auto msg{ActionStmtChecker<IsCUFKernelDo>::WhyNotOk (x)}) {
354386 context_.Say (source, std::move (*msg));
0 commit comments