aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMikael Morin <mikael.morin@tele2.fr>2008-11-24 13:37:25 +0100
committerMikael Morin <mikael@gcc.gnu.org>2008-11-24 12:37:25 +0000
commit5b19c351a4f1dc42504e2867883f71f7bd122cbb (patch)
tree483cc327075a03c6a738cc67d06944510fec6e5c
parentc32f57c054225a1fd2a83e498cb6131a5bfdabea (diff)
downloadgcc-5b19c351a4f1dc42504e2867883f71f7bd122cbb.zip
gcc-5b19c351a4f1dc42504e2867883f71f7bd122cbb.tar.gz
gcc-5b19c351a4f1dc42504e2867883f71f7bd122cbb.tar.bz2
re PR fortran/35681 (wrong result for vector subscripted array expression in MVBITS)
2008-11-24 Mikael Morin <mikael.morin@tele2.fr> PR fortran/35681 * gfortran.dg/elemental_dependency_1.f90: Really commit it. From-SVN: r142155
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/gfortran.dg/elemental_dependency_1.f9083
2 files changed, 88 insertions, 0 deletions
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 1ccc573..734759d 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2008-11-24 Mikael Morin <mikael.morin@tele2.fr>
+
+ PR fortran/35681
+ * gfortran.dg/elemental_dependency_1.f90: Really commit it.
+
2008-11-24 Paul Thomas <pault@gcc.gnu.org>
PR fortran/34820
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 0000000..3e1f67b
--- /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\.17\\\[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\.26\\\[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\.38\\\[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" } }