Hi Steve,

That certainly does the trick! OK to commit as far back as you have
the intestinal fortitude for.

Thanks

Paul

On Tue, 6 Aug 2019 at 19:24, Steve Kargl
<s...@troutmask.apl.washington.edu> wrote:
>
> The spaghetti code in PR fortran/91359 has a few gotos
> to jump to different places.  In doing so, gfortran
> with generate a function that has a naked 'return'.
> Namely,
>
> foo ()
> {
>   logical(kind=4) __result_foo;
>
>   goto __label_000002;
>   __label_000001:;
>   return;             /* <-- THIS IS BAD.  */
>   __label_000002:;
>   __result_foo = 0;
>   if (!__result_foo) goto __label_000001;
>   L.1:;
>   return __result_foo;
>   return __result_foo;
> }
>
> The attached patch avoids the naked 'return' by
> adding the variable that is constructed from the
> the function name.  Namely,
>
> foo ()
> {
>   logical(kind=4) __result_foo;
>
>   goto __label_000002;
>   __label_000001:;
>   return __result_foo;    /* <-- THIS IS GOOD.  */
>   __label_000002:;
>   __result_foo = 0;
>   if (!__result_foo) goto __label_000001;
>   L.1:;
>   return __result_foo;
>   return __result_foo;
> }
>
> Regression tested on x86_64-*-freebsd.  OK to commit?
>
> 2019-08-06  Steven G. Kargl  <ka...@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  <ka...@gcc.gnu.org>
>
>         PR fortran/91359
>         * gfortran.dg/pr91359_1.f: New test.
>         * gfortran.dg/pr91359_2.f: Ditto.
>
> --
> Steve



-- 
"If you can't explain it simply, you don't understand it well enough"
- Albert Einstein

Reply via email to