From 554fd8c5195424bdbcabf5de30fdc183aba391bd Mon Sep 17 00:00:00 2001 From: upstream source tree Date: Sun, 15 Mar 2015 20:14:05 -0400 Subject: obtained gcc-4.6.4.tar.bz2 from upstream website; verified gcc-4.6.4.tar.bz2.sig; imported gcc-4.6.4 source tree from verified upstream tarball. downloading a git-generated archive based on the 'upstream' tag should provide you with a source tree that is binary identical to the one extracted from the above tarball. if you have obtained the source via the command 'git clone', however, do note that line-endings of files in your working directory might differ from line-endings of the respective files in the upstream repository. --- .../gfortran.dg/elemental_subroutine_1.f90 | 62 ++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 gcc/testsuite/gfortran.dg/elemental_subroutine_1.f90 (limited to 'gcc/testsuite/gfortran.dg/elemental_subroutine_1.f90') diff --git a/gcc/testsuite/gfortran.dg/elemental_subroutine_1.f90 b/gcc/testsuite/gfortran.dg/elemental_subroutine_1.f90 new file mode 100644 index 000000000..802d1ed20 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/elemental_subroutine_1.f90 @@ -0,0 +1,62 @@ +! { dg-do run } +! Test the fix for pr22146, where and elemental subroutine with +! array actual arguments would cause an ICE in gfc_conv_function_call. +! The module is the original test case and the rest is a basic +! functional test of the scalarization of the function call. +! +! Contributed by Erik Edelmann +! and Paul Thomas + + module pr22146 + +contains + + elemental subroutine foo(a) + integer, intent(out) :: a + a = 0 + end subroutine foo + + subroutine bar() + integer :: a(10) + call foo(a) + end subroutine bar + +end module pr22146 + + use pr22146 + real, dimension (2) :: x, y + real :: u, v + x = (/1.0, 2.0/) + u = 42.0 + + call bar () + +! Check the various combinations of scalar and array. + call foobar (x, y) + if (any(y.ne.-x)) call abort () + + call foobar (u, y) + if (any(y.ne.-42.0)) call abort () + + call foobar (u, v) + if (v.ne.-42.0) call abort () + + v = 2.0 + call foobar (v, x) + if (any(x /= -2.0)) call abort () + +! Test an expression in the INTENT(IN) argument + x = (/1.0, 2.0/) + call foobar (cos (x) + u, y) + if (any(abs (y + cos (x) + u) .gt. 4.0e-6)) call abort () + +contains + + elemental subroutine foobar (a, b) + real, intent(IN) :: a + real, intent(out) :: b + b = -a + end subroutine foobar +end + +! { dg-final { cleanup-modules "pr22146" } } -- cgit v1.2.3