[flang-commits] [flang] dd5ea56 - [flang] Make interactive behaviour more obvious

Richard Barton via flang-commits flang-commits at lists.llvm.org
Fri Jul 31 07:58:10 PDT 2020


Author: Richard Barton
Date: 2020-07-31T15:56:37+01:00
New Revision: dd5ea5674b86bade4904fab4c66a1156b3df033e

URL: https://github.com/llvm/llvm-project/commit/dd5ea5674b86bade4904fab4c66a1156b3df033e
DIFF: https://github.com/llvm/llvm-project/commit/dd5ea5674b86bade4904fab4c66a1156b3df033e.diff

LOG: [flang] Make interactive behaviour more obvious

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

Added: 
    flang/test/Driver/Inputs/hello.f90
    flang/test/Driver/no_files.f90

Modified: 
    flang/tools/f18/f18.cpp

Removed: 
    


################################################################################
diff  --git a/flang/test/Driver/Inputs/hello.f90 b/flang/test/Driver/Inputs/hello.f90
new file mode 100644
index 000000000000..d0c7eb94f53c
--- /dev/null
+++ b/flang/test/Driver/Inputs/hello.f90
@@ -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
index 000000000000..718985dce4ca
--- /dev/null
+++ b/flang/test/Driver/no_files.f90
@@ -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

diff  --git a/flang/tools/f18/f18.cpp b/flang/tools/f18/f18.cpp
index dc5ddd12295f..5df78a467f2b 100644
--- a/flang/tools/f18/f18.cpp
+++ b/flang/tools/f18/f18.cpp
@@ -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;
   }


        


More information about the flang-commits mailing list