summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gfortran.dg/elemental_dependency_1.f90
diff options
context:
space:
mode:
authorupstream source tree <ports@midipix.org>2015-03-15 20:14:05 -0400
committerupstream source tree <ports@midipix.org>2015-03-15 20:14:05 -0400
commit554fd8c5195424bdbcabf5de30fdc183aba391bd (patch)
tree976dc5ab7fddf506dadce60ae936f43f58787092 /gcc/testsuite/gfortran.dg/elemental_dependency_1.f90
downloadcbb-gcc-4.6.4-554fd8c5195424bdbcabf5de30fdc183aba391bd.tar.bz2
cbb-gcc-4.6.4-554fd8c5195424bdbcabf5de30fdc183aba391bd.tar.xz
obtained gcc-4.6.4.tar.bz2 from upstream website;upstream
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.
Diffstat (limited to 'gcc/testsuite/gfortran.dg/elemental_dependency_1.f90')
-rw-r--r--gcc/testsuite/gfortran.dg/elemental_dependency_1.f9083
1 files changed, 83 insertions, 0 deletions
diff --git a/gcc/testsuite/gfortran.dg/elemental_dependency_1.f90 b/gcc/testsuite/gfortran.dg/elemental_dependency_1.f90
new file mode 100644
index 000000000..d76fad642
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/elemental_dependency_1.f90
@@ -0,0 +1,83 @@
+! { dg-do run }
+! { dg-options "-fdump-tree-original" }
+!
+! PR fortran/35681
+! Test the use of temporaries in case of elemental subroutines.
+
+PROGRAM main
+ IMPLICIT NONE
+ INTEGER, PARAMETER :: sz = 5
+ INTEGER :: i
+ INTEGER :: a(sz) = (/ (i, i=1,sz) /)
+ INTEGER :: b(sz)
+
+ b = a
+ CALL double(a(sz-b+1), a) ! { dg-warning "might interfere with actual" }
+ ! Don't check the result, as the above is invalid
+ ! and might produce unexpected results (overlapping vector subscripts).
+
+
+ b = a
+ CALL double (a, a) ! same range, no temporary
+ IF (ANY(a /= 2*b)) CALL abort
+
+
+ b = a
+ CALL double (a+1, a) ! same range, no temporary
+ IF (ANY(a /= 2*b+2)) CALL abort
+
+
+ b = a
+ CALL double ((a(1:sz)), a(1:sz)) ! same range, no temporary
+ IF (ANY(a /= 2*b)) CALL abort
+
+
+ b = a
+ CALL double(a(1:sz-1), a(2:sz)) ! { dg-warning "might interfere with actual" }
+ ! Don't check the result, as the above is invalid,
+ ! and might produce unexpected results (arguments overlap).
+
+
+ b = a
+ CALL double((a(1:sz-1)), a(2:sz)) ! paren expression, temporary created
+! { dg-final { scan-tree-dump-times "A\.16\\\[4\\\]" 1 "original" } }
+
+ IF (ANY(a /= (/ b(1), (2*b(i), i=1,sz-1) /))) CALL abort
+
+
+ b = a
+ CALL double(a(1:sz-1)+1, a(2:sz)) ! op expression, temporary created
+! { dg-final { scan-tree-dump-times "A\.25\\\[4\\\]" 1 "original" } }
+
+ IF (ANY(a /= (/ b(1), (2*b(i)+2, i=1,sz-1) /))) CALL abort
+
+
+ b = a
+ CALL double(self(a), a) ! same range, no temporary
+ IF (ANY(a /= 2*b)) CALL abort
+
+
+ b = a
+ CALL double(self(a(1:sz-1)), a(2:sz)) ! function expr, temporary created
+! { dg-final { scan-tree-dump-times "A\.37\\\[4\\\]" 1 "original" } }
+
+ IF (ANY(a /= (/ b(1), (2*b(i), i=1,sz-1) /))) CALL abort
+
+
+CONTAINS
+ ELEMENTAL SUBROUTINE double(a, b)
+ IMPLICIT NONE
+ INTEGER, INTENT(IN) :: a
+ INTEGER, INTENT(OUT) :: b
+ b = 2 * a
+ END SUBROUTINE double
+ ELEMENTAL FUNCTION self(a)
+ IMPLICIT NONE
+ INTEGER, INTENT(IN) :: a
+ INTEGER :: self
+ self = a
+ END FUNCTION self
+END PROGRAM main
+
+! { dg-final { scan-tree-dump-times "_gfortran_internal_unpack" 3 "original" } }
+! { dg-final { cleanup-tree-dump "original" } }