Re: [PATCH] PR fortran/91359 -- A function should return something

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH] PR fortran/91359 -- A function should return something

Paul Richard Thomas
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
<[hidden email]> 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  <[hidden email]>
>
>         PR fortran/91359
>         * trans-decl.c (gfc_generate_return): Ensure something is returned
>         from a function.
>
> 2019-08-06  Steven G. Kargl  <[hidden email]>
>
>         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 | Threaded
Open this post in threaded view
|

Re: [PATCH] PR fortran/91359 -- A function should return something

Harald Anlauf-3
Hi Steve,

not a review, just quick comments:

The testcases need small adjustments to what they test;
there should be no STOP in case of success.

! { dg do }

should be

! { dg-do run }

Also I do not see any difference between the two files,
what am I missing?

Cheers,
Harald
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH] PR fortran/91359 -- A function should return something

Steve Kargl
On Tue, Aug 06, 2019 at 11:12:43PM +0200, Harald Anlauf wrote:

>
> not a review, just quick comments:
>
> The testcases need small adjustments to what they test;
> there should be no STOP in case of success.
>
> ! { dg do }
>
> should be
>
> ! { dg-do run }
>
> Also I do not see any difference between the two files,
> what am I missing?
>

Thanks!  I was just getting ready to do a last round
of testing before committing.  I'll adjust the testcases
according.

--
Steve
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH] PR fortran/91359 -- A function should return something

Harald Anlauf-3
Steve,

sorry to bother again:

On 08/06/19 23:15, Steve Kargl wrote:
> On Tue, Aug 06, 2019 at 11:12:43PM +0200, Harald Anlauf wrote:
>> ! { dg do }
>>
>> should be
>>
>> ! { dg-do run }

Well, you missed the "-":

! { dg do run }

Is not the same.  Please look at the gfortran.sum and
gfortran.log to verify that there is a difference!

>> Also I do not see any difference between the two files,
>> what am I missing?
>>

I think you want to change one of the testcases such that one uses
a RESULT variable ("result(a)", that apparently worked before),
and the other without RESULT (which tests for the previous bug).

> Thanks!  I was just getting ready to do a last round
> of testing before committing.  I'll adjust the testcases
> according.

Cheers,
Harald

Reply | Threaded
Open this post in threaded view
|

Re: [PATCH] PR fortran/91359 -- A function should return something

Steve Kargl
On Wed, Aug 07, 2019 at 08:53:13PM +0200, Harald Anlauf wrote:

> Steve,
>
> sorry to bother again:
>
> On 08/06/19 23:15, Steve Kargl wrote:
> > On Tue, Aug 06, 2019 at 11:12:43PM +0200, Harald Anlauf wrote:
> >> ! { dg do }
> >>
> >> should be
> >>
> >> ! { dg-do run }
>
> Well, you missed the "-":
>
> ! { dg do run }
>
> Is not the same.  Please look at the gfortran.sum and
> gfortran.log to verify that there is a difference!

Arrgh.  I'll fix it.

--
Steve