2019-08-06 Steven G. Kargl <kargl@gcc.gnu.org>
+ PR fortran/91359
+ * trans-decl.c (gfc_generate_return): Ensure something is returned
+ from a function.
+
+2019-08-06 Steven G. Kargl <kargl@gcc.gnu.org>
+
PR fortran/42546
* check.c(gfc_check_allocated): Add comment pointing to ...
* intrinsic.c(sort_actual): ... the checking done here.
TREE_TYPE (result), DECL_RESULT (fndecl),
result);
}
+ else
+ {
+ /* If the function does not have a result variable, result is
+ NULL_TREE, and a 'return' is generated without a variable.
+ The following generates a 'return __result_XXX' where XXX is
+ the function name. */
+ if (sym == sym->result && sym->attr.function)
+ {
+ result = gfc_get_fake_result_decl (sym, 0);
+ result = fold_build2_loc (input_location, MODIFY_EXPR,
+ TREE_TYPE (result),
+ DECL_RESULT (fndecl), result);
+ }
+ }
}
return build1_v (RETURN_EXPR, result);
2019-08-06 Steven G. Kargl <kargl@gcc.gnu.org>
+ PR fortran/91359
+ * gfortran.dg/pr91359_1.f: New test.
+ * gfortran.dg/pr91359_2.f: Ditto.
+
+2019-08-06 Steven G. Kargl <kargl@gcc.gnu.org>
+
PR fortran/42546
* gfortran.dg/allocated_1.f90: New test.
* gfortran.dg/allocated_2.f90: Ditto.
--- /dev/null
+! { dg do run }
+! PR fortran/91359
+! Orginal code contributed by Brian T. Carcich <briantcarcich at gmail dot com>
+!
+ logical function zero() result(a)
+ goto 2
+1 return
+2 a = .false.
+ if (.not.a) goto 1
+ return
+ end
+
+ program test_zero
+ logical zero
+ if (zero()) stop 1
+ end
--- /dev/null
+! { dg do run }
+! PR fortran/91359
+! Orginal code contributed by Brian T. Carcich <briantcarcich at gmail dot com>
+!
+ logical function zero() result(a)
+ goto 2
+1 return
+2 a = .false.
+ if (.not.a) goto 1
+ return
+ end
+
+ program test_zero
+ logical zero
+ if (zero()) stop 1
+ end