File tree 2 files changed +13
-9
lines changed
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 {
340
340
void ErrorIfHostSymbol (const A &expr, parser::CharBlock source) {
341
341
if (const Symbol * hostArray{FindHostArray{}(expr)}) {
342
342
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,
344
344
hostArray->name ());
345
345
}
346
346
}
@@ -387,13 +387,10 @@ template <bool IsCUFKernelDo> class DeviceContextChecker {
387
387
Check (x.value ());
388
388
},
389
389
[&](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);
397
394
}
398
395
if (auto msg{ActionStmtChecker<IsCUFKernelDo>::WhyNotOk (x)}) {
399
396
context_.Say (source, std::move (*msg));
Original file line number Diff line number Diff line change 1
1
! RUN: %python %S/test_errors.py %s %flang_fc1
2
2
module m
3
+ integer :: m(100)
3
4
contains
4
5
attributes(device) subroutine devsub
5
6
!ERROR: Statement may not appear in device code
@@ -15,6 +16,12 @@ module m
15
16
!WARNING: I/O statement might not be supported on device
16
17
write(12,'(10F4.1)'), x
17
18
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
18
25
end
19
26
20
27
program main
@@ -96,7 +103,7 @@ program main
96
103
!$cuf kernel do (2) <<<*, *>>>
97
104
do j = 1, 10
98
105
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
100
107
a_d(i,j) = b(i,j)
101
108
enddo
102
109
enddo
You can’t perform that action at this time.
0 commit comments