[flang-commits] [PATCH] D91375: [flang] Include source information in an invalid file-unit-number message

Peter Klausler via Phabricator via flang-commits flang-commits at lists.llvm.org
Thu Nov 12 13:12:42 PST 2020


This revision was automatically updated to reflect the committed changes.
Closed by commit rG04a147987a6b: [flang] Include source information in an invalid file-unit-number message (authored by klausler).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D91375/new/

https://reviews.llvm.org/D91375

Files:
  flang/lib/Semantics/rewrite-parse-tree.cpp
  flang/test/Semantics/io04.f90


Index: flang/test/Semantics/io04.f90
===================================================================
--- flang/test/Semantics/io04.f90
+++ flang/test/Semantics/io04.f90
@@ -87,6 +87,9 @@
   !ERROR: If UNIT=* appears, REC must not appear
   write(*, rec=13) 'Ok'
 
+  !ERROR: Must have INTEGER type, but is REAL(4)
+  write(unit, *) 'Ok'
+
   !ERROR: If ADVANCE appears, UNIT=internal-file must not appear
   write(internal_file, advance='yes', fmt=1) 'Ok'
 
Index: flang/lib/Semantics/rewrite-parse-tree.cpp
===================================================================
--- flang/lib/Semantics/rewrite-parse-tree.cpp
+++ flang/lib/Semantics/rewrite-parse-tree.cpp
@@ -110,6 +110,8 @@
   return true;
 }
 
+// Convert a syntactically ambiguous io-unit internal-file-variable to a
+// file-unit-number.
 void RewriteMutator::Post(parser::IoUnit &x) {
   if (auto *var{std::get_if<parser::Variable>(&x.u)}) {
     const parser::Name &last{parser::GetLastName(*var)};
@@ -118,11 +120,13 @@
       // If the Variable is not known to be character (any kind), transform
       // the I/O unit in situ to a FileUnitNumber so that automatic expression
       // constraint checking will be applied.
+      auto source{var->GetSource()};
       auto expr{std::visit(
           [](auto &&indirection) {
             return parser::Expr{std::move(indirection)};
           },
           std::move(var->u))};
+      expr.source = source;
       x.u = parser::FileUnitNumber{
           parser::ScalarIntExpr{parser::IntExpr{std::move(expr)}}};
     }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D91375.304948.patch
Type: text/x-patch
Size: 1549 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/flang-commits/attachments/20201112/1a9951bc/attachment.bin>


More information about the flang-commits mailing list