Commit b1fc7763 by Mark Eggleston Committed by Mark Eggleston

Replace test cases for using automatic variables in equivalence statements.

From-SVN: r276580
parent 3694418a
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.
......
! { 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
! { 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 }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment