URL
https://opencores.org/ocsvn/openrisc/openrisc/trunk
Subversion Repositories openrisc
[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [testsuite/] [gfortran.dg/] [aliasing_array_result_1.f90] - Rev 700
Go to most recent revision | Compare with Previous | Blame | View Log
! { dg-do run }! Tests the fic for PR44582, where gfortran was found to! produce an incorrect result when the result of a function! was aliased by a host or use associated variable, to which! the function is assigned. In these cases a temporary is! required in the function assignments. The check has to be! rather restrictive. Whilst the cases marked below might! not need temporaries, the TODOs are going to be tough.!! Reported by Yin Ma <yin@absoft.com> and! elaborated by Tobias Burnus <burnus@gcc.gnu.org>!module fooINTEGER, PARAMETER :: ONE = 1INTEGER, PARAMETER :: TEN = 10INTEGER, PARAMETER :: FIVE = TEN/2INTEGER, PARAMETER :: TWO = 2integer :: foo_a(ONE)integer :: check(ONE) = TENLOGICAL :: abort_flag = .false.containsfunction foo_f()integer :: foo_f(ONE)foo_f = -FIVEfoo_f = foo_a - foo_fend function foo_fsubroutine barfoo_a = FIVE! This aliases 'foo_a' by host association.foo_a = foo_f ()if (any (foo_a .ne. check)) call myabort (0)end subroutine barsubroutine myabort(fl)integer :: flprint *, flabort_flag = .true.end subroutine myabortend module foofunction h_ext()use foointeger :: h_ext(ONE)h_ext = -FIVEh_ext = FIVE - h_extend function h_extfunction i_ext() result (h)use foointeger :: h(ONE)h = -FIVEh = FIVE - hend function i_extsubroutine tobiasuse foointeger :: a(ONE)a = FIVEcall sub1(a)if (any (a .ne. check)) call myabort (1)containssubroutine sub1(x)integer :: x(ONE)! 'x' is aliased by host association in 'f'.x = f()end subroutine sub1function f()integer :: f(ONE)f = ONEf = a + FIVEend function fend subroutine tobiasprogram testuse fooimplicit nonecommon /foo_bar/ cinteger :: a(ONE), b(ONE), c(ONE), d(ONE)interfacefunction h_ext()use foointeger :: h_ext(ONE)end function h_extend interfaceinterfacefunction i_ext() result (h)use foointeger :: h(ONE)end function i_extend interfacea = FIVE! This aliases 'a' by host associationa = f()if (any (a .ne. check)) call myabort (2)a = FIVEif (any (f() .ne. check)) call myabort (3)call barfoo_a = FIVE! This aliases 'foo_a' by host association.foo_a = g ()if (any (foo_a .ne. check)) call myabort (4)a = FIVEa = h() ! TODO: Needs no temporaryif (any (a .ne. check)) call myabort (5)a = FIVEa = i() ! TODO: Needs no temporaryif (any (a .ne. check)) call myabort (6)a = FIVEa = h_ext() ! Needs no temporary - was OKif (any (a .ne. check)) call myabort (15)a = FIVEa = i_ext() ! Needs no temporary - was OKif (any (a .ne. check)) call myabort (16)c = FIVE! This aliases 'c' through the common block.c = j()if (any (c .ne. check)) call myabort (7)call aaacall tobiasif (abort_flag) call abortcontainsfunction f()integer :: f(ONE)f = -FIVEf = a - fend function ffunction g()integer :: g(ONE)g = -FIVEg = foo_a - gend function gfunction h()integer :: h(ONE)h = -FIVEh = FIVE - hend function hfunction i() result (h)integer :: h(ONE)h = -FIVEh = FIVE - hend function ifunction j()common /foo_bar/ ccinteger :: j(ONE), cc(ONE)j = -FIVEj = cc - jend function jsubroutine aaa()d = TEN - TWO! This aliases 'd' through 'get_d'.d = bbb()if (any (d .ne. check)) call myabort (8)end subroutine aaafunction bbb()integer :: bbb(ONE)bbb = TWObbb = bbb + get_d()end function bbbfunction get_d()integer :: get_d(ONE)get_d = dend function get_dend program test! { dg-final { cleanup-modules "foo" } }
Go to most recent revision | Compare with Previous | Blame | View Log
