aboutsummaryrefslogtreecommitdiff
path: root/flang/lib/Frontend/CompilerInvocation.cpp
diff options
context:
space:
mode:
authorPeter Klausler <pklausler@nvidia.com>2021-11-18 11:48:42 -0800
committerPeter Klausler <pklausler@nvidia.com>2021-11-22 10:06:38 -0800
commit996ef895cd3d1313665a42fc8e20d1d4e1cf2a28 (patch)
treeae63aee1d702ce7b6a30a558e94fccfc4459e058 /flang/lib/Frontend/CompilerInvocation.cpp
parented8b5b37abb12bd8e7bf7b3f8ec28187ad79a927 (diff)
downloadllvm-996ef895cd3d1313665a42fc8e20d1d4e1cf2a28.zip
llvm-996ef895cd3d1313665a42fc8e20d1d4e1cf2a28.tar.gz
llvm-996ef895cd3d1313665a42fc8e20d1d4e1cf2a28.tar.bz2
[flang] Add -fno-automatic, refine IsSaved()
This legacy option (available in other Fortran compilers with various spellings) implies the SAVE attribute for local variables on subprograms that are not explicitly RECURSIVE. The SAVE attribute essentially implies static rather than stack storage. This was the default setting in Fortran until surprisingly recently, so explicit SAVE statements & attributes could be and often were omitted from older codes. Note that initialized objects already have an implied SAVE attribute, and objects in COMMON effectively do too, as data overlays are extinct; and since objects that are expected to survive from one invocation of a procedure to the next in static storage should probably be explicit initialized in the first place, so the use cases for this option are somewhat rare, and all of them could be handled with explicit SAVE statements or attributes. This implicit SAVE attribute must not apply to automatic (in the Fortran sense) local objects, whose sizes cannot be known at compilation time. To get the semantics of IsSaved() right, the IsAutomatic() predicate was moved into Evaluate/tools.cpp to allow for dynamic linking of the compiler. The redundant predicate IsAutomatic() was noticed, removed, and its uses replaced. GNU Fortran's spelling of the option (-fno-automatic) was added to the clang-based driver and used for basic sanity testing. Differential Revision: https://reviews.llvm.org/D114209
Diffstat (limited to 'flang/lib/Frontend/CompilerInvocation.cpp')
-rw-r--r--flang/lib/Frontend/CompilerInvocation.cpp5
1 files changed, 5 insertions, 0 deletions
diff --git a/flang/lib/Frontend/CompilerInvocation.cpp b/flang/lib/Frontend/CompilerInvocation.cpp
index c16c969..acdfcb8 100644
--- a/flang/lib/Frontend/CompilerInvocation.cpp
+++ b/flang/lib/Frontend/CompilerInvocation.cpp
@@ -310,6 +310,11 @@ static bool ParseFrontendArgs(FrontendOptions &opts, llvm::opt::ArgList &args,
args.hasFlag(clang::driver::options::OPT_fxor_operator,
clang::driver::options::OPT_fno_xor_operator, false));
+ // -fno-automatic
+ if (args.hasArg(clang::driver::options::OPT_fno_automatic)) {
+ opts.features.Enable(Fortran::common::LanguageFeature::DefaultSave);
+ }
+
if (args.hasArg(
clang::driver::options::OPT_falternative_parameter_statement)) {
opts.features.Enable(Fortran::common::LanguageFeature::OldStyleParameter);