diff options
author | Mark Eggleston <mark.eggleston@codethink.com> | 2019-10-04 14:11:36 +0000 |
---|---|---|
committer | Mark Eggleston <markeggleston@gcc.gnu.org> | 2019-10-04 14:11:36 +0000 |
commit | b1fc776335a5d905f6ca37cb0e158613b04d0dc3 (patch) | |
tree | 0e7aee6ec5e722847c6519257efd77618068d089 /gcc | |
parent | 3694418a6d57c5b48383af8a5c6d1b1c2e3cec9b (diff) | |
download | gcc-b1fc776335a5d905f6ca37cb0e158613b04d0dc3.zip gcc-b1fc776335a5d905f6ca37cb0e158613b04d0dc3.tar.gz gcc-b1fc776335a5d905f6ca37cb0e158613b04d0dc3.tar.bz2 |
Replace test cases for using automatic variables in equivalence statements.
From-SVN: r276580
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/testsuite/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/testsuite/gfortran.dg/auto_in_equiv_1.f90 | 53 | ||||
-rw-r--r-- | gcc/testsuite/gfortran.dg/auto_in_equiv_2.f90 | 46 |
3 files changed, 43 insertions, 62 deletions
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 5c5d869..c5ead9f 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2019-10-04 Mark Eggleston <mark.eggleston@codethink.com> + + * 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 <richard.sandiford@arm.com> * 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 bf6e0c6..2791675 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 <mark.eggleston@codethink.com> +! +! 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 e40c0f1..5d8a9fb 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 <mark.eggleston@codethink.com> - -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 } |