Commit 7c71e796 by Paul Thomas

re PR fortran/82923 (Automatic allocation of deferred length character using function result)

2018-05-19  Paul Thomas  <pault@gcc.gnu.org>

	PR fortran/82923
	PR fortran/66694
	PR fortran/82617
	* trans-array.c (gfc_alloc_allocatable_for_assignment): Set the
	charlen backend_decl of the rhs expr to ss->info->string_length
	so that the value in the current scope is used.

2018-05-19  Paul Thomas  <pault@gcc.gnu.org>

	PR fortran/82923
	* gfortran.dg/allocate_assumed_charlen_4.f90: New test. Note
	that the patch fixes PR66694 & PR82617, although the testcases
	are not explicitly included.

From-SVN: r260413
parent 69e7672a
2018-05-20 Paul Thomas <pault@gcc.gnu.org>
PR fortran/82275
* match.c (gfc_match_type_spec): Go through the array ref and
decrement 'rank' for every dimension that is an element.
2018-05-19 Paul Thomas <pault@gcc.gnu.org> 2018-05-19 Paul Thomas <pault@gcc.gnu.org>
PR fortran/82923 PR fortran/82923
......
...@@ -5935,6 +5935,7 @@ copy_ts_from_selector_to_associate (gfc_expr *associate, gfc_expr *selector) ...@@ -5935,6 +5935,7 @@ copy_ts_from_selector_to_associate (gfc_expr *associate, gfc_expr *selector)
{ {
gfc_ref *ref; gfc_ref *ref;
gfc_symbol *assoc_sym; gfc_symbol *assoc_sym;
int rank = 0;
assoc_sym = associate->symtree->n.sym; assoc_sym = associate->symtree->n.sym;
...@@ -5971,17 +5972,31 @@ copy_ts_from_selector_to_associate (gfc_expr *associate, gfc_expr *selector) ...@@ -5971,17 +5972,31 @@ copy_ts_from_selector_to_associate (gfc_expr *associate, gfc_expr *selector)
selector->rank = ref->u.ar.dimen; selector->rank = ref->u.ar.dimen;
else else
selector->rank = 0; selector->rank = 0;
rank = selector->rank;
} }
if (selector->rank) if (rank)
{
for (int i = 0; i < ref->u.ar.dimen + ref->u.ar.codimen; i++)
if (ref->u.ar.dimen_type[i] == DIMEN_ELEMENT
|| (ref->u.ar.dimen_type[i] == DIMEN_UNKNOWN
&& ref->u.ar.end[i] == NULL
&& ref->u.ar.stride[i] == NULL))
rank--;
if (rank)
{ {
assoc_sym->attr.dimension = 1; assoc_sym->attr.dimension = 1;
assoc_sym->as = gfc_get_array_spec (); assoc_sym->as = gfc_get_array_spec ();
assoc_sym->as->rank = selector->rank; assoc_sym->as->rank = rank;
assoc_sym->as->type = AS_DEFERRED; assoc_sym->as->type = AS_DEFERRED;
} }
else else
assoc_sym->as = NULL; assoc_sym->as = NULL;
}
else
assoc_sym->as = NULL;
if (selector->ts.type == BT_CLASS) if (selector->ts.type == BT_CLASS)
{ {
......
2018-05-20 Paul Thomas <pault@gcc.gnu.org>
PR fortran/82923
* gfortran.dg/select_type_42.f90: New test.
2018-05-19 Paul Thomas <pault@gcc.gnu.org> 2018-05-19 Paul Thomas <pault@gcc.gnu.org>
PR fortran/82923 PR fortran/82923
......
! { dg-do run }
!
! Tests the fix for PR82275.
! Associating a name with a reduced-dimension section of a
! multidimensional array precluded subsequent use of the name
! with the appropriately reduced dimensionality and instead
! required use of the (invalid) full set of original dimensions.
!
! Contributed by Damian Rouson <damian@sourceryinstitute.org>
!
type component
integer :: i
end type
type container
class(component), allocatable :: component_array(:,:)
end type
type(container) bag
type(component) section_copy
allocate(bag%component_array, source = reshape ([component(10), component (100)], [1,2]))
select type(associate_name=>bag%component_array(1,:))
type is (component)
section_copy = associate_name(2) ! gfortran rejected valid
! section_copy = associate_name(1,1)! gfortran accepted invalid
end select
if (section_copy%i .ne. 100) stop 1
end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment