summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gfortran.dg/internal_pack_12.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/internal_pack_12.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/internal_pack_12.f90')
-rw-r--r--gcc/testsuite/gfortran.dg/internal_pack_12.f9061
1 files changed, 61 insertions, 0 deletions
diff --git a/gcc/testsuite/gfortran.dg/internal_pack_12.f90 b/gcc/testsuite/gfortran.dg/internal_pack_12.f90
new file mode 100644
index 000000000..32bacfa39
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/internal_pack_12.f90
@@ -0,0 +1,61 @@
+! { dg-do compile }
+! { dg-options "-fdump-tree-original" }
+!
+! Test the fix for PR43243, where unnecessary calls to internal_pack/unpack
+! were being produced below. These references are contiguous and so do not
+! need a temporary. In addition, the final call to 'bar' required a pack/unpack
+! which had been missing since r156680, at least.
+!
+! Contributed Tobias Burnus <burnus@gcc.gnu.org>
+!
+module m
+ type t
+ integer, allocatable :: a(:)
+ integer, pointer :: b(:)
+ integer :: c(5)
+ end type t
+end module m
+
+subroutine foo(a,d,e,n)
+ use m
+ implicit none
+ integer :: n
+ type(t) :: a
+ type(t), allocatable :: d(:)
+ type(t), pointer :: e(:)
+ call bar( a%a) ! OK - no array temp needed
+ call bar( a%c) ! OK - no array temp needed
+
+ call bar( a%a(1:n)) ! Missed: No pack needed
+ call bar( a%b(1:n)) ! OK: pack needed
+ call bar( a%c(1:n)) ! Missed: No pack needed
+
+ call bar(d(1)%a(1:n)) ! Missed: No pack needed
+ call bar(d(1)%b(1:n)) ! OK: pack needed
+ call bar(d(1)%c(1:n)) ! Missed: No pack needed
+
+ call bar(e(1)%a(1:n)) ! Missed: No pack needed
+ call bar(e(1)%b(1:n)) ! OK: pack needed
+ call bar(e(1)%c(1:n)) ! Missed: No pack needed
+end subroutine foo
+
+use m
+implicit none
+integer :: i
+integer, target :: z(6)
+type(t) :: y
+
+z = [(i, i=1,6)]
+y%b => z(::2)
+call bar(y%b) ! Missed: Pack needed
+end
+
+subroutine bar(x)
+ integer :: x(1:*)
+ print *, x(1:3)
+ if (any (x(1:3) /= [1,3,5])) call abort ()
+end subroutine bar
+! { dg-final { scan-tree-dump-times "unpack" 4 "original" } }
+! { dg-final { cleanup-tree-dump "original" } }
+! { dg-final { cleanup-modules "m" } }
+