File tree Expand file tree Collapse file tree 2 files changed +19
-1
lines changed Expand file tree Collapse file tree 2 files changed +19
-1
lines changed Original file line number Diff line number Diff line change @@ -480,10 +480,16 @@ void CUDAChecker::Enter(const parser::CUFKernelDoConstruct &x) {
480
480
}
481
481
482
482
void CUDAChecker::Enter (const parser::AssignmentStmt &x) {
483
+ auto lhsLoc{std::get<parser::Variable>(x.t ).GetSource ()};
484
+ const auto &scope{context_.FindScope (lhsLoc)};
485
+ const Scope &progUnit{GetProgramUnitContaining (scope)};
486
+ if (IsCUDADeviceContext (&progUnit)) {
487
+ return ; // Data transfer with assignment is only perform on host.
488
+ }
489
+
483
490
const evaluate::Assignment *assign{semantics::GetAssignment (x)};
484
491
int nbLhs{evaluate::GetNbOfCUDASymbols (assign->lhs )};
485
492
int nbRhs{evaluate::GetNbOfCUDASymbols (assign->rhs )};
486
- auto lhsLoc{std::get<parser::Variable>(x.t ).GetSource ()};
487
493
488
494
// device to host transfer with more than one device object on the rhs is not
489
495
// legal.
Original file line number Diff line number Diff line change 1
1
! RUN: %python %S/test_errors.py %s %flang_fc1
2
2
3
+ module mod1
4
+ contains
5
+ attributes(global) subroutine sub1(adev)
6
+ real :: adev(10)
7
+ integer :: tid
8
+ tid = threadIdx%x
9
+ ! Use to crash the compiler. Make sure we have the proper semantic error.
10
+ !ERROR: Actual argument for 'i=' has bad type 'REAL(4)'
11
+ adev(tid + 1) = scale(real(tid), 2.0)
12
+ end subroutine sub1
13
+ end module
14
+
3
15
subroutine sub1()
4
16
real, device :: adev(10), bdev(10)
5
17
real :: ahost(10)
You can’t perform that action at this time.
0 commit comments