[flang] Make interactive behaviour more obvious
authorRichard Barton <richard.barton@arm.com>
Fri, 17 Jul 2020 08:15:21 +0000 (09:15 +0100)
committerRichard Barton <richard.barton@arm.com>
Fri, 31 Jul 2020 14:56:37 +0000 (15:56 +0100)
When flang is invoked with no files it waits for input on stdin. Make it
print a message saying this to prevent the user being surprised.

Differential Revision: https://reviews.llvm.org/D84855

flang/test/Driver/Inputs/hello.f90 [new file with mode: 0644]
flang/test/Driver/no_files.f90 [new file with mode: 0644]
flang/tools/f18/f18.cpp

diff --git a/flang/test/Driver/Inputs/hello.f90 b/flang/test/Driver/Inputs/hello.f90
new file mode 100644 (file)
index 0000000..d0c7eb9
--- /dev/null
@@ -0,0 +1,3 @@
+program hello
+  write (*,*), "hello world" 
+end program hello
diff --git a/flang/test/Driver/no_files.f90 b/flang/test/Driver/no_files.f90
new file mode 100644 (file)
index 0000000..718985d
--- /dev/null
@@ -0,0 +1,10 @@
+! RUN: %f18 < %S/Inputs/hello.f90 | FileCheck %s
+
+
+! CHECK: Enter Fortran source
+! CHECK: Use EOF character (^D) to end file
+
+! CHECK: Parse tree comprises {{.*}} objects and occupies {{.*}} total bytes
+! CHECK: PROGRAM hello
+! CHECK:  WRITE (*, *) "hello world"
+! CHECK: END PROGRAM hello
index dc5ddd1..5df78a4 100644 (file)
@@ -686,6 +686,8 @@ int main(int argc, char *const argv[]) {
   if (!anyFiles) {
     driver.measureTree = true;
     driver.dumpUnparse = true;
+    llvm::outs() << "Enter Fortran source\n"
+                 << "Use EOF character (^D) to end file\n";
     CompileFortran("-", options, driver, defaultKinds);
     return exitStatus;
   }