File tree Expand file tree Collapse file tree 2 files changed +13
-9
lines changed Expand file tree Collapse file tree 2 files changed +13
-9
lines changed Original file line number Diff line number Diff line change @@ -340,7 +340,7 @@ template <bool IsCUFKernelDo> class DeviceContextChecker {
340340 void ErrorIfHostSymbol (const A &expr, parser::CharBlock source) {
341341 if (const Symbol * hostArray{FindHostArray{}(expr)}) {
342342 context_.Say (source,
343- " Host array '%s' cannot be present in CUF kernel " _err_en_US,
343+ " Host array '%s' cannot be present in device context " _err_en_US,
344344 hostArray->name ());
345345 }
346346 }
@@ -387,13 +387,10 @@ template <bool IsCUFKernelDo> class DeviceContextChecker {
387387 Check (x.value ());
388388 },
389389 [&](const common::Indirection<parser::AssignmentStmt> &x) {
390- if (IsCUFKernelDo) {
391- const evaluate::Assignment *assign{
392- semantics::GetAssignment (x.value ())};
393- if (assign) {
394- ErrorIfHostSymbol (assign->lhs , source);
395- ErrorIfHostSymbol (assign->rhs , source);
396- }
390+ if (const evaluate::Assignment *
391+ assign{semantics::GetAssignment (x.value ())}) {
392+ ErrorIfHostSymbol (assign->lhs , source);
393+ ErrorIfHostSymbol (assign->rhs , source);
397394 }
398395 if (auto msg{ActionStmtChecker<IsCUFKernelDo>::WhyNotOk (x)}) {
399396 context_.Say (source, std::move (*msg));
Original file line number Diff line number Diff line change 11! RUN: %python %S/test_errors.py %s %flang_fc1
22module m
3+ integer :: m(100)
34 contains
45 attributes(device) subroutine devsub
56 !ERROR: Statement may not appear in device code
@@ -15,6 +16,12 @@ module m
1516 !WARNING: I/O statement might not be supported on device
1617 write(12,'(10F4.1)'), x
1718 end
19+ attributes(global) subroutine hostglobal(a)
20+ integer :: a(*)
21+ i = threadIdx%x
22+ !ERROR: Host array 'm' cannot be present in device context
23+ if (i .le. N) a(i) = m(i)
24+ end subroutine
1825end
1926
2027program main
@@ -96,7 +103,7 @@ program main
96103 !$cuf kernel do (2) <<<*, *>>>
97104 do j = 1, 10
98105 do i = 1, 10
99- !ERROR: Host array 'b' cannot be present in CUF kernel
106+ !ERROR: Host array 'b' cannot be present in device context
100107 a_d(i,j) = b(i,j)
101108 enddo
102109 enddo
You can’t perform that action at this time.
0 commit comments