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) {
785785 for (const auto &item : outputItemList) {
786786 if (const auto *x{std::get_if<parser::Expr>(&item.u )}) {
787787 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+ }
791799 }
792800 }
793801 }
Original file line number Diff line number Diff line change 11! RUN: %python %S/test_errors.py %s %flang_fc1 -fopenacc
22
3+ module devicemod
4+ real, constant :: c(10)
5+ end module
6+
37program test
8+ use devicemod
49 real, device :: a(10)
10+ real, managed :: m(10)
511 a = 1.0
612!ERROR: device data not allowed in I/O statements
713 print *, a(1)
814!ERROR: device data not allowed in I/O statements
915 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)
1024end
1125
1226subroutine host()
You can’t perform that action at this time.
0 commit comments