1 From 348c7b9400ed5fe0d8c3c077f8223ca359bed036 Mon Sep 17 00:00:00 2001
2 From: pault <pault@138bc75d-0d04-0410-961f-82ee72b054a4>
3 Date: Wed, 13 Apr 2011 18:38:17 +0000
4 Subject: [PATCH 116/200] 2011-04-13 Paul Thomas <pault@gcc.gnu.org>
8 * trans-array.c (get_std_lbound): For derived type variables
9 return array valued component lbound.
11 2011-04-13 Paul Thomas <pault@gcc.gnu.org>
15 * gfortran.dg/realloc_on_assign_6.f03: New test.
17 git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gcc-4_6-branch@172390 138bc75d-0d04-0410-961f-82ee72b054a4
19 index ac08c42..3d4a52a 100644
20 --- a/gcc/fortran/trans-array.c
21 +++ b/gcc/fortran/trans-array.c
22 @@ -6707,6 +6707,8 @@ get_std_lbound (gfc_expr *expr, tree desc, int dim, bool assumed_size)
24 tree cond, cond1, cond3, cond4;
28 if (GFC_DESCRIPTOR_TYPE_P (TREE_TYPE (desc)))
30 tmp = gfc_rank_cst[dim];
31 @@ -6740,6 +6742,14 @@ get_std_lbound (gfc_expr *expr, tree desc, int dim, bool assumed_size)
32 else if (expr->expr_type == EXPR_VARIABLE)
34 tmp = TREE_TYPE (expr->symtree->n.sym->backend_decl);
35 + for (ref = expr->ref; ref; ref = ref->next)
37 + if (ref->type == REF_COMPONENT
38 + && ref->u.c.component->as
40 + && ref->next->u.ar.type == AR_FULL)
41 + tmp = TREE_TYPE (ref->u.c.component->backend_decl);
43 return GFC_TYPE_ARRAY_LBOUND(tmp, dim);
45 else if (expr->expr_type == EXPR_FUNCTION)
47 index 0000000..7c170eb
49 +++ b/gcc/testsuite/gfortran.dg/realloc_on_assign_6.f03
52 +! Test the fix for PR48456 and PR48360 in which the backend
53 +! declarations for components were not located in the automatic
54 +! reallocation on assignments, thereby causing ICEs.
56 +! Contributed by Keith Refson <krefson@googlemail.com>
57 +! and Douglas Foulds <mixnmaster@gmail.com>
63 + real, dimension(3,3) :: h0
69 + real, allocatable, save, dimension(:,:) :: hmat
80 + end subroutine assignit
87 +integer, parameter :: dp = kind(0.d0)
90 + real(dp), dimension(5) :: some_vector
94 + type(my_type_sub) :: some_element
97 +end module custom_type
99 +module custom_interfaces
102 + subroutine store_data_subroutine(vec_size)
104 + integer, intent(in) :: vec_size
106 + end subroutine store_data_subroutine
109 +end module custom_interfaces
111 +module store_data_test
116 +type(my_type), dimension(:), allocatable :: some_type_to_save
118 +end module store_data_test
128 +call store_data_subroutine(vec_size)
129 +call print_after_transfer()
133 +subroutine store_data_subroutine(vec_size)
140 +integer, intent(in) :: vec_size
143 +allocate(some_type_to_save(vec_size))
147 + some_type_to_save(k)%some_element%some_vector(1) = 1.0_dp
148 + some_type_to_save(k)%some_element%some_vector(2) = 2.0_dp
149 + some_type_to_save(k)%some_element%some_vector(3) = 3.0_dp
150 + some_type_to_save(k)%some_element%some_vector(4) = 4.0_dp
151 + some_type_to_save(k)%some_element%some_vector(5) = 5.0_dp
155 +end subroutine store_data_subroutine
157 +subroutine print_after_transfer()
164 +real(dp), dimension(:), allocatable :: C_vec
169 +do k = 1,size(some_type_to_save)
171 + C_vec = some_type_to_save(k)%some_element%some_vector
172 + print *, "C_vec", C_vec
176 +end subroutine print_after_transfer
177 +! { dg-final { cleanup-modules "m gf33" } }
178 +! { dg-final { cleanup-modules "custom_type custom_interfaces" } }
179 +! { dg-final { cleanup-modules "store_data_test" } }