===================================================================
@@ -7278,7 +7278,8 @@
@option{-O3} optimizations. It also enables optimizations that are not
valid for all standard-compliant programs.
It turns on @option{-ffast-math} and the Fortran-specific
-@option{-fno-protect-parens} and @option{-fstack-arrays}.
+@option{-fstack-arrays}, unless @option{-fmax-stack-var-size} is
+specified, and @option{-fno-protect-parens}.
@item -Og
@opindex Og
===================================================================
@@ -1570,13 +1570,13 @@
@item -fstack-arrays
@opindex @code{fstack-arrays}
-Adding this option will make the Fortran compiler put all local arrays,
-even those of unknown size onto stack memory. If your program uses very
+Adding this option will make the Fortran compiler put all arrays of
+unknown size and array temporaries onto stack memory. If your program uses very
large local arrays it is possible that you will have to extend your runtime
limits for stack memory on some operating systems. This flag is enabled
-by default at optimization level @option{-Ofast}.
+by default at optimization level @option{-Ofast} unless
+@option{-fmax-stack-var-size} is specified.
-
@item -fpack-derived
@opindex @code{fpack-derived}
@cindex structure packing
===================================================================
@@ -235,7 +235,9 @@
if (flag_protect_parens == -1)
flag_protect_parens = !optimize_fast;
- if (flag_stack_arrays == -1)
+ /* -Ofast sets implies -fstack-arrays unless an explicit size is set for
+ stack arrays. */
+ if (flag_stack_arrays == -1 && flag_max_stack_var_size == -2)
flag_stack_arrays = optimize_fast;
/* By default, disable (re)allocation during assignment for -std=f95,
@@ -380,6 +382,10 @@
flag_max_stack_var_size = -1;
}
+ /* Set flag_stack_arrays correctly. */
+ if (flag_stack_arrays == -1)
+ flag_stack_arrays = 0;
+
/* Set default. */
if (flag_max_stack_var_size == -2)
flag_max_stack_var_size = 32768;