Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 5 additions & 8 deletions flang/lib/Semantics/check-cuda.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ template <bool IsCUFKernelDo> class DeviceContextChecker {
void ErrorIfHostSymbol(const A &expr, parser::CharBlock source) {
if (const Symbol * hostArray{FindHostArray{}(expr)}) {
context_.Say(source,
"Host array '%s' cannot be present in CUF kernel"_err_en_US,
"Host array '%s' cannot be present in device context"_err_en_US,
hostArray->name());
}
}
Expand Down Expand Up @@ -387,13 +387,10 @@ template <bool IsCUFKernelDo> class DeviceContextChecker {
Check(x.value());
},
[&](const common::Indirection<parser::AssignmentStmt> &x) {
if (IsCUFKernelDo) {
const evaluate::Assignment *assign{
semantics::GetAssignment(x.value())};
if (assign) {
ErrorIfHostSymbol(assign->lhs, source);
ErrorIfHostSymbol(assign->rhs, source);
}
if (const evaluate::Assignment *
assign{semantics::GetAssignment(x.value())}) {
ErrorIfHostSymbol(assign->lhs, source);
ErrorIfHostSymbol(assign->rhs, source);
}
if (auto msg{ActionStmtChecker<IsCUFKernelDo>::WhyNotOk(x)}) {
context_.Say(source, std::move(*msg));
Expand Down
9 changes: 8 additions & 1 deletion flang/test/Semantics/cuf09.cuf
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
! RUN: %python %S/test_errors.py %s %flang_fc1
module m
integer :: m(100)
contains
attributes(device) subroutine devsub
!ERROR: Statement may not appear in device code
Expand All @@ -15,6 +16,12 @@ module m
!WARNING: I/O statement might not be supported on device
write(12,'(10F4.1)'), x
end
attributes(global) subroutine hostglobal(a)
integer :: a(*)
i = threadIdx%x
!ERROR: Host array 'm' cannot be present in device context
if (i .le. N) a(i) = m(i)
end subroutine
end

program main
Expand Down Expand Up @@ -96,7 +103,7 @@ program main
!$cuf kernel do (2) <<<*, *>>>
do j = 1, 10
do i = 1, 10
!ERROR: Host array 'b' cannot be present in CUF kernel
!ERROR: Host array 'b' cannot be present in device context
a_d(i,j) = b(i,j)
enddo
enddo
Expand Down
Loading