re PR fortran/53818 (-finit-local-zero -fno-automatic: Function result cannot have...
authorTobias Burnus <burnus@net-b.de>
Fri, 15 Feb 2013 08:50:37 +0000 (09:50 +0100)
committerTobias Burnus <burnus@gcc.gnu.org>
Fri, 15 Feb 2013 08:50:37 +0000 (09:50 +0100)
2013-02-15  Tobias Burnus  <burnus@net-b.de>

        PR fortran/53818
        * resolve.c (apply_default_init_local): Don't create an
        initializer for a result variable.

2013-02-15  Tobias Burnus  <burnus@net-b.de>

        PR fortran/53818
        * gfortran.dg/init_flag_11.f90: New.

From-SVN: r196073

gcc/fortran/ChangeLog
gcc/fortran/resolve.c
gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.dg/init_flag_11.f90 [new file with mode: 0644]

index 1375d0e..fff83c4 100644 (file)
@@ -1,3 +1,9 @@
+2013-02-15  Tobias Burnus  <burnus@net-b.de>
+
+       PR fortran/53818
+       * resolve.c (apply_default_init_local): Don't create an
+       initializer for a result variable.
+
 2013-02-14  Thomas Koenig  <tkoenig@gcc.gnu.org>
 
        PR fortran/56224
index b5faaca..a29fef9 100644 (file)
@@ -11031,9 +11031,10 @@ apply_default_init_local (gfc_symbol *sym)
 
   /* For saved variables, we don't want to add an initializer at function
      entry, so we just add a static initializer. Note that automatic variables
-     are stack allocated even with -fno-automatic.  */
+     are stack allocated even with -fno-automatic; we have also to exclude
+     result variable, which are also nonstatic.  */
   if (sym->attr.save || sym->ns->save_all
-      || (gfc_option.flag_max_stack_var_size == 0
+      || (gfc_option.flag_max_stack_var_size == 0 && !sym->attr.result
          && (!sym->attr.dimension || !is_non_constant_shape_array (sym))))
     {
       /* Don't clobber an existing initializer!  */
index fafc6f8..077f536 100644 (file)
@@ -1,3 +1,8 @@
+2013-02-15  Tobias Burnus  <burnus@net-b.de>
+
+       PR fortran/53818
+       * gfortran.dg/init_flag_11.f90: New.
+
 2013-02-14  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>
 
        * gcc.dg/debug/dwarf2/pr53948.c: Allow for more whitespace.
diff --git a/gcc/testsuite/gfortran.dg/init_flag_11.f90 b/gcc/testsuite/gfortran.dg/init_flag_11.f90
new file mode 100644 (file)
index 0000000..7a5239f
--- /dev/null
@@ -0,0 +1,11 @@
+! { dg-do compile }
+! { dg-flags "-finit-local-zero -fno-automatic"
+!
+! PR fortran/53818
+!
+! Contributed by John Moyard
+!
+logical function testing(date1, date2) result(test)
+  integer  date1, date2
+  test = ( (date1 < date2) .or. ( date1==date2 ))
+end function testing