[flang] More f90_correct work.

Original-commit: flang-compiler/f18@442771db3c24ed3b5482a0bfb016ea2ac0bb9556
Reviewed-on: https://github.com/flang-compiler/f18/pull/26
Tree-same-pre-rewrite: false
diff --git a/flang/lib/parser/unparse.cc b/flang/lib/parser/unparse.cc
index e5fb49c..9ad19c9 100644
--- a/flang/lib/parser/unparse.cc
+++ b/flang/lib/parser/unparse.cc
@@ -1494,6 +1494,14 @@
     Word("REWIND ("), Walk(x.v, ", "), Put(')');
     return false;
   }
+  bool Pre(const PositionOrFlushSpec &x) {  // R1227 & R1229
+    std::visit(visitors{[&](const FileUnitNumber &) { Word("UNIT="); },
+                   [&](const MsgVariable &) { Word("IOMSG="); },
+                   [&](const StatVariable &) { Word("IOSTAT="); },
+                   [&](const ErrLabel &) { Word("ERR="); }},
+        x.u);
+    return true;
+  }
   bool Pre(const FlushStmt &x) {  // R1228
     Word("FLUSH ("), Walk(x.v, ", "), Put(')');
     return false;
@@ -1782,8 +1790,16 @@
     return false;
   }
   bool Pre(const CallStmt &x) {  // R1521
-    Word("CALL "), Walk(std::get<ProcedureDesignator>(x.v.t));
-    Walk("(", std::get<std::list<ActualArgSpec>>(x.v.t), ", ", ")");
+    const auto &pd = std::get<ProcedureDesignator>(x.v.t);
+    const auto &args = std::get<std::list<ActualArgSpec>>(x.v.t);
+    Word("CALL "), Walk(pd);
+    if (args.empty()) {
+      if (std::holds_alternative<ProcComponentRef>(pd.u)) {
+        Put("()");  // pgf90 crashes on CALL to tbp without parentheses
+      }
+    } else {
+      Walk("(", args, ", ", ")");
+    }
     return false;
   }
   bool Pre(const ActualArgSpec &x) {  // R1523