From: Mark Eggleston Date: Fri, 4 Oct 2019 14:11:36 +0000 (+0000) Subject: Replace test cases for using automatic variables in equivalence statements. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=b1fc776335a5d905f6ca37cb0e158613b04d0dc3;p=gcc.git Replace test cases for using automatic variables in equivalence statements. From-SVN: r276580 --- diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 5c5d8697639..c5ead9fb30f 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2019-10-04 Mark Eggleston + + * gfortran.dg/auto_in_equiv_1.f90: Replaced. + * gfortran.dg/auto_in_equiv_2.f90: Replaced. + * gfortran.dg/auto_in_equiv_3.f90: Deleted. + 2019-10-04 Richard Sandiford * gcc.target/aarch64/torture/simd-abi-8.c: Use -mlittle-endian. diff --git a/gcc/testsuite/gfortran.dg/auto_in_equiv_1.f90 b/gcc/testsuite/gfortran.dg/auto_in_equiv_1.f90 index bf6e0c68a57..2791675af1b 100644 --- a/gcc/testsuite/gfortran.dg/auto_in_equiv_1.f90 +++ b/gcc/testsuite/gfortran.dg/auto_in_equiv_1.f90 @@ -1,36 +1,35 @@ -! { dg-do compile } +! { dg-do run } +! { dg-options "-fdec-static -frecursive" } ! Contributed by Mark Eggleston +! +! Check automatic variables can be used in equivalence statements. +! Any other variables that do not explicitly have the automatic +! attribute will be given the automatic attribute. +! +! Check that variables are on the stack by incorporating the +! equivalence in a recursive function. +! program test - call suba(0) - call subb(0) - call suba(1) + integer :: f + + f = factorial(5) + if (f.ne.120) stop 2 contains - subroutine suba(option) - integer, intent(in) :: option - integer, automatic :: a ! { dg-error "AUTOMATIC at \\(1\\) is a DEC extension" } + function factorial(n) result(f) + integer :: f + integer, intent(in) :: n + integer, automatic :: a integer :: b - integer :: c - equivalence (a, b) - if (option.eq.0) then - ! initialise a and c - a = 9 - c = 99 - if (a.ne.b) stop 1 - if (loc(a).ne.loc(b)) stop 2 + equivalence (a,b) + + if (loc(a).ne.loc(b)) stop 1 + b = n + if (a.eq.1) then + f = 1 else - ! a should've been overwritten - if (a.eq.9) stop 3 + f = a * factorial(b-1) end if - end subroutine suba - - subroutine subb(dummy) - integer, intent(in) :: dummy - integer, automatic :: x ! { dg-error "AUTOMATIC at \\(1\\) is a DEC extension" } - integer :: y - x = 77 - y = 7 - end subroutine subb - + end function end program test diff --git a/gcc/testsuite/gfortran.dg/auto_in_equiv_2.f90 b/gcc/testsuite/gfortran.dg/auto_in_equiv_2.f90 index e40c0f15f3e..5d8a9fbb90e 100644 --- a/gcc/testsuite/gfortran.dg/auto_in_equiv_2.f90 +++ b/gcc/testsuite/gfortran.dg/auto_in_equiv_2.f90 @@ -1,38 +1,14 @@ ! { dg-do run } -! { dg-options "-fdec-static" } +! { dg-options "-fdec-static -frecursive -fno-automatic" } ! Contributed by Mark Eggleston - -program test - call suba(0) - call subb(0) - call suba(1) - -contains - subroutine suba(option) - integer, intent(in) :: option - integer, automatic :: a - integer :: b - integer :: c - equivalence (a, b) - if (option.eq.0) then - ! initialise a and c - a = 9 - c = 99 - if (a.ne.b) stop 1 - if (loc(a).ne.loc(b)) stop 2 - else - ! a should've been overwritten - if (a.eq.9) stop 3 - end if - end subroutine suba - - subroutine subb(dummy) - integer, intent(in) :: dummy - integer, automatic :: x - integer :: y - x = 77 - y = 7 - end subroutine subb - -end program test +! +! Check that -fno-automatic does not break recursion. The recursive +! function is not marked with the resursive key word consequently +! local variables can be made static when -fno-automatic is used. The +! recursive function contains an equivalence that has a variable with +! the automatic attribute and one without. +! +include "auto_in_equiv_1.f90" + +! { dg-warning "Flag '-fno-automatic' overwrites '-frecursive'" "warning" { target *-*-* } 0 }