[PATCH, Fortran] Fix Automatics in equivalence test cases was Re: Automatics in Equivalences failures

Mark Eggleston mark.eggleston@codethink.co.uk
Thu Oct 17 07:53:00 GMT 2019


On 04/10/2019 11:39, Jakub Jelinek wrote:
> On Wed, Oct 02, 2019 at 03:31:53PM +0100, Mark Eggleston wrote:
>> It was there because the code base has -fno-automatic for procedures are
>> that aren't recursive and the -frecursive was used because the recursive
>> routines don't have the recursive keyword. (Legacy issues...). It is to
>> ensure that the use of -fno-automatic does not affect local variables in
>> recursive routine.
> Ah, seems while -frecursive -fno-automatic emits a warning that can be read
> that as if -frecursive is ignored, it just forces all (unless explicitly automatic)
> variables to be saved, but still allows recursion.  One just has to manually
> arrange for the variables that shouldn't be saved to be automatic.
> So, I'm not against that test.
>> If a procedure is marked with the keyword recursive all its local variables
>> are always automatic by default. If a procedure is not marked with the
>> keyword recursive its variables are not automatic when -fno-automatic is
>> used unless they have the automatic attribute specified directly or acquired
>> via the equivalence statement, recursion can still be effected using
>> -frecursive provided all the variables used by the recursion are automatic.
>>
>>>> +! { dg-warning "Flag '-fno-automatic' overwrites '-frecursive'" "warning" { target *-*-* } 0 }
>>> I think you want one runtime test (e.g. the one you wrote in
>>> automatics_in_equivalence_1.f90)
>> The errors checked there only check that automatic can be used that's
>> already covered by dec_static_3.f90 and automatic can't be used in
>> equivalence with the use of -fdec-static.
>>>    and the rest just dg-do compile tests that
>>> will check the original or gimple dumps to verify what happened in addition
>>> to checking diagnostics (none) from the compilation, one testing the
>>> default, another -fno-automatic, but in both cases without -frecursive.
>> Not sure what you mean, here. Are these already handled by the tests for
>> -fdec-static?
> I meant add a couple of new tests.  One like:
> ! { dg-do compile }
> ! { dg-options "-fdump-tree-original" }
> ! { dg-final { scan-tree-dump "static union" "original" } }
>
> subroutine foo
>    integer, save :: a, b
>    equivalence (a, b)
>    a = 5
>    if (b.ne.5) stop 1
> end subroutine
>
> which verifies that the equivalence is saved in that case.  Another one
> like:
> ! { dg-do compile }
> ! { dg-options "-fdec-static -fdump-tree-original -fno-automatic" }
> ! { dg-final { scan-tree-dump-not "static union" "original" } }
>
> subroutine foo
>    integer, automatic :: a
>    integer :: b
>    equivalence (a, b)
>    a = 5
>    if (b.ne.5) stop 1
> end subroutine
>
> another one perhaps with swapped ", automatic" between a and b.
> Another two without the -fno-automatic?
>
> 	Jakub

Please find attached patch for additional test cases. Are these 
sufficient? If so, OK to commit?

Change log:

     Mark Eggleston <mark.eggleston@codethink.com>

     * gfortran.dg/auto_in_equiv_3.f90: New test.
     * gfortran.dg/auto_in_equiv_4.f90: New test.
     * gfortran.dg/auto_in_equiv_5.f90: New test.
     * gfortran.dg/auto_in_equiv_6.f90: New test.
     * gfortran.dg/auto_in_equiv_7.f90: New test.

-- 
https://www.codethink.co.uk/privacy.html

-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-New-Automatics-in-equivalences-test-cases.patch
Type: text/x-patch
Size: 5016 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20191017/8f795346/attachment.bin>


More information about the Gcc-patches mailing list