diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 54700c62638..c1e27634306 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,9 @@ +2013-01-12 Janus Weil + + PR fortran/55072 + * trans-array.c (gfc_conv_array_parameter): No packing was done for + full arrays of derived type. + 2013-01-08 Paul Thomas PR fortran/55868 diff --git a/gcc/fortran/trans-array.c b/gcc/fortran/trans-array.c index d292eac03e1..088a29973f0 100644 --- a/gcc/fortran/trans-array.c +++ b/gcc/fortran/trans-array.c @@ -7002,20 +7002,14 @@ gfc_conv_array_parameter (gfc_se * se, gfc_expr * expr, bool g77, this_array_result = false; /* Passing address of the array if it is not pointer or assumed-shape. */ - if (full_array_var && g77 && !this_array_result) + if (full_array_var && g77 && !this_array_result + && sym->ts.type != BT_DERIVED && sym->ts.type != BT_CLASS) { tmp = gfc_get_symbol_decl (sym); if (sym->ts.type == BT_CHARACTER) se->string_length = sym->ts.u.cl->backend_decl; - if (sym->ts.type == BT_DERIVED || sym->ts.type == BT_CLASS) - { - gfc_conv_expr_descriptor (se, expr); - se->expr = gfc_conv_array_data (se->expr); - return; - } - if (!sym->attr.pointer && sym->as && sym->as->type != AS_ASSUMED_SHAPE diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 868f5aa555c..f847f1b7a3e 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,10 @@ +2013-01-12 Janus Weil + + PR fortran/55072 + * gfortran.dg/assumed_type_2.f90: Fix test case. + * gfortran.dg/internal_pack_13.f90: New test. + * gfortran.dg/internal_pack_14.f90: New test. + 2013-01-08 Paul Thomas PR fortran/55868 diff --git a/gcc/testsuite/gfortran.dg/assumed_type_2.f90 b/gcc/testsuite/gfortran.dg/assumed_type_2.f90 index ab1049d216e..28d38a16982 100644 --- a/gcc/testsuite/gfortran.dg/assumed_type_2.f90 +++ b/gcc/testsuite/gfortran.dg/assumed_type_2.f90 @@ -157,7 +157,7 @@ end ! { dg-final { scan-tree-dump-times "sub_scalar .\\(struct t1 .\\) array_class_t1_alloc._data.data" 1 "original" } } ! { dg-final { scan-tree-dump-times "sub_scalar .\\(struct t1 .\\) array_class_t1_ptr._data.dat" 1 "original" } }a -! { dg-final { scan-tree-dump-times "sub_array_assumed \\(D" 2 "original" } } +! { dg-final { scan-tree-dump-times "sub_array_assumed \\(D" 3 "original" } } ! { dg-final { scan-tree-dump-times " = _gfortran_internal_pack \\(&parm" 1 "original" } } ! { dg-final { scan-tree-dump-times "sub_array_assumed \\(&array_int\\)" 1 "original" } } ! { dg-final { scan-tree-dump-times "sub_array_assumed \\(\\(real\\(kind=4\\).0:. . restrict\\) array_real_alloc.data" 1 "original" } } @@ -165,7 +165,6 @@ end ! { dg-final { scan-tree-dump-times "\\.data = \\(void .\\) &array_t1.0.;" 1 "original" } } ! { dg-final { scan-tree-dump-times "sub_array_assumed \\(\\(struct t1.0:. .\\) parm" 1 "original" } } ! { dg-final { scan-tree-dump-times "sub_array_assumed \\(\\(struct t2.0:. . restrict\\) array_t2_alloc.data\\);" 1 "original" } } -! { dg-final { scan-tree-dump-times "sub_array_assumed \\(\\(struct t3.0:. .\\) array_t3_ptr.data\\);" 1 "original" } } ! { dg-final { scan-tree-dump-times "sub_array_assumed \\(\\(struct t1.0:. . restrict\\) array_class_t1_alloc._data.data\\);" 1 "original" } } ! { dg-final { scan-tree-dump-times "sub_array_assumed \\(\\(struct t1.0:. .\\) array_class_t1_ptr._data.data\\);" 1 "original" } } diff --git a/gcc/testsuite/gfortran.dg/internal_pack_13.f90 b/gcc/testsuite/gfortran.dg/internal_pack_13.f90 new file mode 100644 index 00000000000..21fdc541878 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/internal_pack_13.f90 @@ -0,0 +1,34 @@ +! { dg-do run } +! +! PR 55072: [4.6/4.7/4.8 Regression] Missing internal_pack leads to wrong code with derived type +! +! Contributed by Tobias Burnus + +implicit none +type t +integer :: i +end type t +type(t), target :: tgt(4,4) +type(t), pointer :: p(:,:) +integer :: i,j,k + +k = 1 +do i = 1, 4 + do j = 1, 4 + tgt(i,j)%i = k + k = k+1 + end do +end do + +p => tgt(::2,::2) +print *,p%i +call bar(p) + +contains + + subroutine bar(x) + type(t) :: x(*) + print *,x(1:4)%i + if (any (x(1:4)%i /= [1, 9, 3, 11])) call abort() + end subroutine +end diff --git a/gcc/testsuite/gfortran.dg/internal_pack_14.f90 b/gcc/testsuite/gfortran.dg/internal_pack_14.f90 new file mode 100644 index 00000000000..1a4b3725fbb --- /dev/null +++ b/gcc/testsuite/gfortran.dg/internal_pack_14.f90 @@ -0,0 +1,34 @@ +! { dg-do run } +! +! PR 55072: [4.6/4.7/4.8 Regression] Missing internal_pack leads to wrong code with derived type +! +! Contributed by Janus Weil + +program GiBUU_neutrino_bug + + Type particle + integer :: ID + End Type + + type(particle), dimension(1:2,1:2) :: OutPart + + OutPart(1,:)%ID = 1 + OutPart(2,:)%ID = 2 + + call s1(OutPart(1,:)) + +contains + + subroutine s1(j) + type(particle) :: j(:) + print *,j(:)%ID + call s2(j) + end subroutine + + subroutine s2(k) + type(particle) :: k(1:2) + print *,k(:)%ID + if (any (k(1:2)%ID /= [1, 1])) call abort() + end subroutine + +end