2012-07-02  Tobias Burnus  <burnus@net-b.de>

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

2012-07-02  Tobias Burnus  <burnus@net-b.de>

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

diff --git a/gcc/fortran/resolve.c b/gcc/fortran/resolve.c
index 0434e08..c7f14a2 100644
--- a/gcc/fortran/resolve.c
+++ b/gcc/fortran/resolve.c
@@ -10269,7 +10328,7 @@ apply_default_init_local (gfc_symbol *sym)
      entry, so we just add a static initializer. Note that automatic variables
      are stack allocated even with -fno-automatic.  */
   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!  */
--- /dev/null	2012-06-30 08:05:14.091716208 +0200
+++ gcc/gcc/testsuite/gfortran.dg/init_flag_11.f90	2012-07-02 08:58:54.000000000 +0200
@@ -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
