Skip to content

Commit 4ad21aa

Browse files
RichBarton-Armzmodem
authored andcommitted
[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 b068d19)
1 parent dfc8459 commit 4ad21aa

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
@@ -602,6 +602,19 @@ int main(int argc, char *const argv[]) {
602602
driver.getSymbolsSources = true;
603603
} else if (arg == "-help" || arg == "--help" || arg == "-?") {
604604
llvm::errs()
605+
<< "f18: LLVM Fortran compiler\n"
606+
<< "\n"
607+
<< "Usage: f18 [options] <input files>\n"
608+
<< "\n"
609+
<< "Defaults:\n"
610+
<< " When invoked with input files, and no options to tell\n"
611+
<< " it otherwise, f18 will unparse its input and pass that on to an\n"
612+
<< " external compiler to continue the compilation.\n"
613+
<< " The external compiler is specified by the F18_FC environment\n"
614+
<< " variable. The default is 'gfortran'.\n"
615+
<< " If invoked with no input files, f18 reads source code from\n"
616+
<< " stdin and runs with -fdebug-measure-parse-tree -funparse.\n"
617+
<< "\n"
605618
<< "f18 options:\n"
606619
<< " -Mfixed | -Mfree | -ffixed-form | -ffree-form force the "
607620
"source form\n"
@@ -635,7 +648,8 @@ int main(int argc, char *const argv[]) {
635648
<< " -fget-symbols-sources\n"
636649
<< " -v -c -o -I -D -U have their usual meanings\n"
637650
<< " -help print this again\n"
638-
<< "Other options are passed through to the compiler.\n";
651+
<< "Unrecognised options are passed through to the external compiler\n"
652+
<< "set by F18_FC (see defaults).\n";
639653
return exitStatus;
640654
} else if (arg == "-V") {
641655
llvm::errs() << "\nf18 compiler (under development)\n";

0 commit comments

Comments
 (0)