Author: Richard Barton Date: 2020-08-18T11:58:20+02:00 New Revision: 4ad21aadae561b95cc9d4bb98e91499cb5342367
URL: https://github.com/llvm/llvm-project/commit/4ad21aadae561b95cc9d4bb98e91499cb5342367 DIFF: https://github.com/llvm/llvm-project/commit/4ad21aadae561b95cc9d4bb98e91499cb5342367.diff LOG: [flang] Add details to --help screen on default behaviour Add a usage string and a defaults section that clarifies: * If no input files are given, f18 reads from stdin * If no input files are given, f18 dumps the parse tree. * The default behaviour is to exec F18_FC. * The fefault F18_FC setting is 'gfortran' Adds a simple regression test which tests the top and tail of the help screen and the exit status. Depends on D84855 Differential Revision: https://reviews.llvm.org/D84856 (cherry picked from commit b068d19a151d9d3a73b0265df27836d9fd0ad1e3) Added: flang/test/Driver/help.f90 Modified: flang/tools/f18/f18.cpp Removed: ################################################################################ diff --git a/flang/test/Driver/help.f90 b/flang/test/Driver/help.f90 new file mode 100644 index 000000000000..66dd14aa5a86 --- /dev/null +++ b/flang/test/Driver/help.f90 @@ -0,0 +1,9 @@ +! RUN: %f18 -help 2>&1 | FileCheck %s +! RUN: %f18 --help 2>&1 | FileCheck %s +! RUN: %f18 -? 2>&1 | FileCheck %s + +! CHECK: f18: LLVM Fortran compiler + +! CHECK: -help print this again +! CHECK: Unrecognised options are passed through to the external compiler +! CHECK: set by F18_FC (see defaults). diff --git a/flang/tools/f18/f18.cpp b/flang/tools/f18/f18.cpp index 83db520d8ff9..9189f6a46aff 100644 --- a/flang/tools/f18/f18.cpp +++ b/flang/tools/f18/f18.cpp @@ -602,6 +602,19 @@ int main(int argc, char *const argv[]) { driver.getSymbolsSources = true; } else if (arg == "-help" || arg == "--help" || arg == "-?") { llvm::errs() + << "f18: LLVM Fortran compiler\n" + << "\n" + << "Usage: f18 [options] <input files>\n" + << "\n" + << "Defaults:\n" + << " When invoked with input files, and no options to tell\n" + << " it otherwise, f18 will unparse its input and pass that on to an\n" + << " external compiler to continue the compilation.\n" + << " The external compiler is specified by the F18_FC environment\n" + << " variable. The default is 'gfortran'.\n" + << " If invoked with no input files, f18 reads source code from\n" + << " stdin and runs with -fdebug-measure-parse-tree -funparse.\n" + << "\n" << "f18 options:\n" << " -Mfixed | -Mfree | -ffixed-form | -ffree-form force the " "source form\n" @@ -635,7 +648,8 @@ int main(int argc, char *const argv[]) { << " -fget-symbols-sources\n" << " -v -c -o -I -D -U have their usual meanings\n" << " -help print this again\n" - << "Other options are passed through to the compiler.\n"; + << "Unrecognised options are passed through to the external compiler\n" + << "set by F18_FC (see defaults).\n"; return exitStatus; } else if (arg == "-V") { llvm::errs() << "\nf18 compiler (under development)\n"; _______________________________________________ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits