diff -up ../_clean/gcc/fortran/resolve.c gcc/fortran/resolve.c --- ../_clean/gcc/fortran/resolve.c 2019-01-15 23:24:11.000000000 +0100 +++ gcc/fortran/resolve.c 2019-01-17 11:45:32.000000000 +0100 @@ -16669,7 +16669,7 @@ resolve_types (gfc_namespace *ns) gfc_traverse_ns (ns, resolve_values); - if (ns->save_all) + if (ns->save_all || !flag_automatic) gfc_save_all (ns); iter_stack = NULL; diff -up ../_clean/gcc/fortran/symbol.c gcc/fortran/symbol.c --- ../_clean/gcc/fortran/symbol.c 2019-01-09 22:54:02.000000000 +0100 +++ gcc/fortran/symbol.c 2019-01-17 11:47:57.000000000 +0100 @@ -1306,7 +1306,8 @@ gfc_add_save (symbol_attribute *attr, sa if (s == SAVE_EXPLICIT) gfc_unset_implicit_pure (NULL); - if (s == SAVE_EXPLICIT && attr->save == SAVE_EXPLICIT) + if (s == SAVE_EXPLICIT && attr->save == SAVE_EXPLICIT + && (flag_automatic || pedantic)) { if (!gfc_notify_std (GFC_STD_LEGACY, "Duplicate SAVE attribute specified at %L", --- ../_clean/gcc/testsuite/gfortran.dg/no-automatic.f90 1970-01-01 01:00:00.000000000 +0100 +++ gcc/testsuite/gfortran.dg/no-automatic.f90 2019-01-16 17:34:49.000000000 +0100 @@ -0,0 +1,20 @@ +! { dg-do run } +! { dg-options "-fno-automatic" } +! +! PR fortran/37835 +! Contributed by Tobias Burnus . +! +subroutine foo(n) + integer :: n + type t + integer :: i = 42 + end type t + type(t) :: myt + if(n==1) myt%i = 2 + print *, myt%i + if (n > 1 .and. myt%i /= 2) stop 1 +end subroutine foo + +call foo(1) +call foo(2) +end --- ../_clean/gcc/fortran/invoke.texi 2019-01-09 22:54:02.000000000 +0100 +++ gcc/fortran/invoke.texi 2019-01-18 11:33:25.000000000 +0100 @@ -1377,6 +1377,9 @@ The default, which is @option{-fautomati variables smaller than the value given by @option{-fmax-stack-var-size}. Use the option @option{-frecursive} to use no static memory. +Local variables or arrays having an explicit @code{SAVE} attribute are +silently ignored unless the @option{-pedantic} option is added. + @item -ff2c @opindex ff2c @cindex calling convention