File tree Expand file tree Collapse file tree 2 files changed +25
-3
lines changed Expand file tree Collapse file tree 2 files changed +25
-3
lines changed Original file line number Diff line number Diff line change @@ -785,9 +785,17 @@ void CUDAChecker::Enter(const parser::PrintStmt &x) {
785
785
for (const auto &item : outputItemList) {
786
786
if (const auto *x{std::get_if<parser::Expr>(&item.u )}) {
787
787
if (const auto *expr{GetExpr (context_, *x)}) {
788
- if (Fortran::evaluate::HasCUDADeviceAttrs (*expr)) {
789
- context_.Say (parser::FindSourceLocation (*x),
790
- " device data not allowed in I/O statements" _err_en_US);
788
+ for (const Symbol &sym : CollectCudaSymbols (*expr)) {
789
+ if (const auto *details = sym.GetUltimate ()
790
+ .detailsIf <semantics::ObjectEntityDetails>()) {
791
+ if (details->cudaDataAttr () &&
792
+ (*details->cudaDataAttr () == common::CUDADataAttr::Device ||
793
+ *details->cudaDataAttr () ==
794
+ common::CUDADataAttr::Constant)) {
795
+ context_.Say (parser::FindSourceLocation (*x),
796
+ " device data not allowed in I/O statements" _err_en_US);
797
+ }
798
+ }
791
799
}
792
800
}
793
801
}
Original file line number Diff line number Diff line change 1
1
! RUN: %python %S/test_errors.py %s %flang_fc1 -fopenacc
2
2
3
+ module devicemod
4
+ real, constant :: c(10)
5
+ end module
6
+
3
7
program test
8
+ use devicemod
4
9
real, device :: a(10)
10
+ real, managed :: m(10)
5
11
a = 1.0
6
12
!ERROR: device data not allowed in I/O statements
7
13
print *, a(1)
8
14
!ERROR: device data not allowed in I/O statements
9
15
print *, a
16
+
17
+ print*, m(9) ! ok
18
+ print*, m ! ok
19
+
20
+ !ERROR: device data not allowed in I/O statements
21
+ print*, c
22
+ !ERROR: device data not allowed in I/O statements
23
+ print*, c(5)
10
24
end
11
25
12
26
subroutine host()
You can’t perform that action at this time.
0 commit comments