[flang-commits] [flang] [flang] Make -fsave-main-program default (PR #137090)

via flang-commits flang-commits at lists.llvm.org
Wed Apr 23 17:09:07 PDT 2025


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-flang-driver

Author: Eugene Epshteyn (eugeneepshteyn)

<details>
<summary>Changes</summary>

There are many Fortran tests that assume that the variables in Fortran main program have implicit SAVE attribute. These tests don't initialize such variables in some cases, relying on them having been automatically initialized to zero. With -fno-save-main-program being the default, such tests encounter undefined behavior.

---
Full diff: https://github.com/llvm/llvm-project/pull/137090.diff


1 Files Affected:

- (modified) flang/lib/Frontend/CompilerInvocation.cpp (+1-1) 


``````````diff
diff --git a/flang/lib/Frontend/CompilerInvocation.cpp b/flang/lib/Frontend/CompilerInvocation.cpp
index 6f87a18d69c3d..a2401bd78c2b8 100644
--- a/flang/lib/Frontend/CompilerInvocation.cpp
+++ b/flang/lib/Frontend/CompilerInvocation.cpp
@@ -820,7 +820,7 @@ static bool parseFrontendArgs(FrontendOptions &opts, llvm::opt::ArgList &args,
   opts.features.Enable(
       Fortran::common::LanguageFeature::SaveMainProgram,
       args.hasFlag(clang::driver::options::OPT_fsave_main_program,
-                   clang::driver::options::OPT_fno_save_main_program, false));
+                   clang::driver::options::OPT_fno_save_main_program, true));
 
   if (args.hasArg(
           clang::driver::options::OPT_falternative_parameter_statement)) {

``````````

</details>


https://github.com/llvm/llvm-project/pull/137090


More information about the flang-commits mailing list