Skip to content

Commit b068d19

Browse files
[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
1 parent dd5ea56 commit b068d19

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

flang/test/Driver/help.f90

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
! RUN: %f18 -help 2>&1 | FileCheck %s
2+
! RUN: %f18 --help 2>&1 | FileCheck %s
3+
! RUN: %f18 -? 2>&1 | FileCheck %s
4+
5+
! CHECK: f18: LLVM Fortran compiler
6+
7+
! CHECK: -help print this again
8+
! CHECK: Unrecognised options are passed through to the external compiler
9+
! CHECK: set by F18_FC (see defaults).

flang/tools/f18/f18.cpp

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -605,6 +605,19 @@ int main(int argc, char *const argv[]) {
605605
driver.byteswapio = true; // TODO: Pass to lowering, generate call
606606
} else if (arg == "-help" || arg == "--help" || arg == "-?") {
607607
llvm::errs()
608+
<< "f18: LLVM Fortran compiler\n"
609+
<< "\n"
610+
<< "Usage: f18 [options] <input files>\n"
611+
<< "\n"
612+
<< "Defaults:\n"
613+
<< " When invoked with input files, and no options to tell\n"
614+
<< " it otherwise, f18 will unparse its input and pass that on to an\n"
615+
<< " external compiler to continue the compilation.\n"
616+
<< " The external compiler is specified by the F18_FC environment\n"
617+
<< " variable. The default is 'gfortran'.\n"
618+
<< " If invoked with no input files, f18 reads source code from\n"
619+
<< " stdin and runs with -fdebug-measure-parse-tree -funparse.\n"
620+
<< "\n"
608621
<< "f18 options:\n"
609622
<< " -Mfixed | -Mfree | -ffixed-form | -ffree-form force the "
610623
"source form\n"
@@ -638,7 +651,8 @@ int main(int argc, char *const argv[]) {
638651
<< " -fget-symbols-sources\n"
639652
<< " -v -c -o -I -D -U have their usual meanings\n"
640653
<< " -help print this again\n"
641-
<< "Other options are passed through to the compiler.\n";
654+
<< "Unrecognised options are passed through to the external compiler\n"
655+
<< "set by F18_FC (see defaults).\n";
642656
return exitStatus;
643657
} else if (arg == "-V") {
644658
llvm::errs() << "\nf18 compiler (under development)\n";

0 commit comments

Comments
 (0)