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. --- gcc/testsuite/gfortran.dg/internal_pack_12.f90 | 61 ++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 gcc/testsuite/gfortran.dg/internal_pack_12.f90 (limited to 'gcc/testsuite/gfortran.dg/internal_pack_12.f90') 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 +! +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" } } + -- cgit v1.2.3