Commit 64b33a7e by Tobias Burnus Committed by Tobias Burnus

re PR fortran/41872 (wrong-code: Issues with allocatable scalars)

2010-01-07  Tobias Burnus  <burnus@net-b.de>

        PR fortran/41872
        * trans-decl.c (gfc_trans_deferred_vars): Don't initialize
        allocatable scalars with SAVE attribute.

2010-01-07  Tobias Burnus  <burnus@net-b.de>

        PR fortran/41872
        * gfortran.dg/allocatable_scalar_7.f90: New test.

From-SVN: r155687
parent 2e8e6a99
2010-01-07 Tobias Burnus <burnus@net-b.de>
PR fortran/41872
* trans-decl.c (gfc_trans_deferred_vars): Don't initialize
allocatable scalars with SAVE attribute.
2010-01-05 Tobias Burnus <burnus@net-b.de> 2010-01-05 Tobias Burnus <burnus@net-b.de>
PR fortran/42517 PR fortran/42517
......
...@@ -3188,7 +3188,10 @@ gfc_trans_deferred_vars (gfc_symbol * proc_sym, tree fnbody) ...@@ -3188,7 +3188,10 @@ gfc_trans_deferred_vars (gfc_symbol * proc_sym, tree fnbody)
|| (sym->ts.type == BT_CLASS || (sym->ts.type == BT_CLASS
&& sym->ts.u.derived->components->attr.allocatable)) && sym->ts.u.derived->components->attr.allocatable))
{ {
/* Nullify and automatic deallocation of allocatable scalars. */ if (!sym->attr.save)
{
/* Nullify and automatic deallocation of allocatable
scalars. */
tree tmp; tree tmp;
gfc_expr *e; gfc_expr *e;
gfc_se se; gfc_se se;
...@@ -3205,15 +3208,19 @@ gfc_trans_deferred_vars (gfc_symbol * proc_sym, tree fnbody) ...@@ -3205,15 +3208,19 @@ gfc_trans_deferred_vars (gfc_symbol * proc_sym, tree fnbody)
/* Nullify when entering the scope. */ /* Nullify when entering the scope. */
gfc_start_block (&block); gfc_start_block (&block);
gfc_add_modify (&block, se.expr, fold_convert (TREE_TYPE (se.expr), gfc_add_modify (&block, se.expr,
fold_convert (TREE_TYPE (se.expr),
null_pointer_node)); null_pointer_node));
gfc_add_expr_to_block (&block, fnbody); gfc_add_expr_to_block (&block, fnbody);
/* Deallocate when leaving the scope. Nullifying is not needed. */ /* Deallocate when leaving the scope. Nullifying is not
tmp = gfc_deallocate_with_status (se.expr, NULL_TREE, true, NULL); needed. */
tmp = gfc_deallocate_with_status (se.expr, NULL_TREE, true,
NULL);
gfc_add_expr_to_block (&block, tmp); gfc_add_expr_to_block (&block, tmp);
fnbody = gfc_finish_block (&block); fnbody = gfc_finish_block (&block);
} }
}
else if (sym->ts.type == BT_CHARACTER) else if (sym->ts.type == BT_CHARACTER)
{ {
gfc_get_backend_locus (&loc); gfc_get_backend_locus (&loc);
......
2010-01-07 Tobias Burnus <burnus@net-b.de>
PR fortran/41872
* gfortran.dg/allocatable_scalar_7.f90: New test.
2010-01-06 Richard Guenther <rguenther@suse.de> 2010-01-06 Richard Guenther <rguenther@suse.de>
* gcc.c-torture/compile/pr42632.c: New testcase. * gcc.c-torture/compile/pr42632.c: New testcase.
......
! { dg-do run }
!
! PR fortran/41872
!
! Allocatable scalars with SAVE
!
program test
implicit none
call sub (0)
call sub (1)
call sub (2)
contains
subroutine sub (no)
integer, intent(in) :: no
integer, allocatable, save :: a
if (no == 0) then
if (allocated (a)) call abort ()
allocate (a)
else if (no == 1) then
if (.not. allocated (a)) call abort ()
deallocate (a)
else
if (allocated (a)) call abort ()
end if
end subroutine sub
end program test
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