mirror of
git://gcc.gnu.org/git/gcc.git
synced 2025-03-21 22:51:06 +08:00
Fortran: Fix problem with allocate initialization [PR99545].
2021-03-15 Paul Thomas <pault@gcc.gnu.org> gcc/fortran/ChangeLog PR fortran/99545 * trans-stmt.c (gfc_trans_allocate): Mark the initialization assignment by setting init_flag. gcc/testsuite/ChangeLog PR fortran/99545 * gfortran.dg/pr99545.f90: New test.
This commit is contained in:
parent
f20fe2cb21
commit
21ced2776a
@ -7001,7 +7001,7 @@ gfc_trans_allocate (gfc_code * code)
|
||||
gfc_expr *init_expr = gfc_expr_to_initialize (expr);
|
||||
gfc_expr *rhs = e3rhs ? e3rhs : gfc_copy_expr (code->expr3);
|
||||
flag_realloc_lhs = 0;
|
||||
tmp = gfc_trans_assignment (init_expr, rhs, false, false, true,
|
||||
tmp = gfc_trans_assignment (init_expr, rhs, true, false, true,
|
||||
false);
|
||||
flag_realloc_lhs = realloc_lhs;
|
||||
/* Free the expression allocated for init_expr. */
|
||||
|
40
gcc/testsuite/gfortran.dg/pr99545.f90
Normal file
40
gcc/testsuite/gfortran.dg/pr99545.f90
Normal file
@ -0,0 +1,40 @@
|
||||
! { dg-do compile }
|
||||
! { dg-options "-fcheck=mem" }
|
||||
!
|
||||
! Test the fix for PR99545, in which the allocate statements caused an ICE.
|
||||
!
|
||||
! Contributed by Juergen Reuter <juergen.reuter@desy.de>
|
||||
!
|
||||
module commands
|
||||
implicit none
|
||||
private
|
||||
|
||||
type, abstract :: range_t
|
||||
integer :: step_mode = 0
|
||||
integer :: n_step = 0
|
||||
end type range_t
|
||||
|
||||
type, extends (range_t) :: range_int_t
|
||||
integer :: i_step = 0
|
||||
end type range_int_t
|
||||
|
||||
type, extends (range_t) :: range_real_t
|
||||
real :: lr_step = 0
|
||||
end type range_real_t
|
||||
|
||||
type :: cmd_scan_t
|
||||
private
|
||||
class(range_t), dimension(:), allocatable :: range
|
||||
contains
|
||||
procedure :: compile => cmd_scan_compile
|
||||
end type cmd_scan_t
|
||||
|
||||
contains
|
||||
|
||||
subroutine cmd_scan_compile (cmd)
|
||||
class(cmd_scan_t), intent(inout) :: cmd
|
||||
allocate (range_int_t :: cmd%range (3))
|
||||
allocate (range_real_t :: cmd%range (3))
|
||||
end subroutine cmd_scan_compile
|
||||
|
||||
end module commands
|
Loading…
x
Reference in New Issue
Block a user