Commit 7090cac9 by Andre Vehreschild

re PR fortran/71936 (ICE in wide_int_to_tree, at tree.c:1487)

gcc/fortran/ChangeLog:

2016-08-08  Andre Vehreschild  <vehre@gcc.gnu.org>

	PR fortran/71936
	* trans-array.c (gfc_array_allocate): When SOURCE= is a function
	stick with the ref of the object to allocate.

gcc/testsuite/ChangeLog:

2016-08-08  Andre Vehreschild  <vehre@gcc.gnu.org>

	PR fortran/71936
	* gfortran.dg/allocate_with_source_21.f03: New test.

From-SVN: r239237
parent 64e56ab0
2016-08-08 Andre Vehreschild <vehre@gcc.gnu.org>
PR fortran/71936
* trans-array.c (gfc_array_allocate): When SOURCE= is a function
stick with the ref of the object to allocate.
2016-08-08 Andre Vehreschild <vehre@gcc.gnu.org>
PR fortran/72698
* trans-stmt.c (gfc_trans_allocate): Prevent generating code for
copy of zero sized string and with it an ICE.
......
......@@ -5431,12 +5431,19 @@ gfc_array_allocate (gfc_se * se, gfc_expr * expr, tree status, tree errmsg,
if (ref->u.ar.type == AR_FULL && expr3 != NULL)
{
gfc_ref *old_ref = ref;
/* F08:C633: Array shape from expr3. */
ref = expr3->ref;
/* Find the last reference in the chain. */
if (!retrieve_last_ref (&ref, &prev_ref))
return false;
{
if (expr3->expr_type == EXPR_FUNCTION
&& gfc_expr_attr (expr3).dimension)
ref = old_ref;
else
return false;
}
alloc_w_e3_arr_spec = true;
}
......
2016-08-08 Andre Vehreschild <vehre@gcc.gnu.org>
PR fortran/71936
* gfortran.dg/allocate_with_source_21.f03: New test.
2016-08-08 Andre Vehreschild <vehre@gcc.gnu.org>
PR fortran/72698
* gfortran.dg/allocate_with_source_20.f03: New test.
......
! { dg-do compile }
! Check fix for pr71936.
! Contributed by Gerhard Steinmetz
program p
type t
end type
call test2()
call test4()
call test1()
call test3()
contains
function f_p()
class(t), pointer :: f_p(:)
nullify(f_p)
end
function f_a()
class(t), allocatable :: f_a(:)
end
subroutine test1()
class(t), allocatable :: x(:)
allocate (x, mold=f_a())
deallocate (x)
allocate (x, source=f_a())
end subroutine
subroutine test2()
class(t), pointer :: x(:)
allocate (x, mold=f_p())
deallocate (x)
allocate (x, source=f_p())
end
subroutine test3()
class(t), pointer :: x(:)
allocate (x, mold=f_a())
deallocate (x)
allocate (x, source=f_a())
end
subroutine test4()
class(t), allocatable :: x(:)
allocate (x, mold=f_p())
deallocate (x)
allocate (x, source=f_p())
end subroutine
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