re PR fortran/50960 ([OOP] vtables not marked as constant)

2011-11-03  Tobias Burnus  <burnus@net-b.de>

        PR fortran/50960
        * trans-decl.c (gfc_finish_var_decl): Mark PARAMETER as
        * TREE_READONLY.

2011-11-03  Tobias Burnus  <burnus@net-b.de>

        PR fortran/50960
        * gfortran.dg/module_parameter_array_refs_2.f90: New.

From-SVN: r180878
This commit is contained in:
Tobias Burnus 2011-11-03 23:32:37 +01:00 committed by Tobias Burnus
parent 42d0058e49
commit 1e4b137661
4 changed files with 37 additions and 0 deletions

View File

@ -1,3 +1,8 @@
2011-11-03 Tobias Burnus <burnus@net-b.de>
PR fortran/50960
* trans-decl.c (gfc_finish_var_decl): Mark PARAMETER as TREE_READONLY.
2011-11-03 Mikael Morin <mikael@gcc.gnu.org> 2011-11-03 Mikael Morin <mikael@gcc.gnu.org>
* trans.h (struct gfc_ss, struct gfc_ss_info): Move field * trans.h (struct gfc_ss, struct gfc_ss_info): Move field

View File

@ -517,6 +517,10 @@ gfc_finish_var_decl (tree decl, gfc_symbol * sym)
/* If it wasn't used we wouldn't be getting it. */ /* If it wasn't used we wouldn't be getting it. */
TREE_USED (decl) = 1; TREE_USED (decl) = 1;
if (sym->attr.flavor == FL_PARAMETER
&& (sym->attr.dimension || sym->ts.type == BT_DERIVED))
TREE_READONLY (decl) = 1;
/* Chain this decl to the pending declarations. Don't do pushdecl() /* Chain this decl to the pending declarations. Don't do pushdecl()
because this would add them to the current scope rather than the because this would add them to the current scope rather than the
function scope. */ function scope. */

View File

@ -1,3 +1,8 @@
2011-11-03 Tobias Burnus <burnus@net-b.de>
PR fortran/50960
* gfortran.dg/module_parameter_array_refs_2.f90: New.
2011-11-03 Richard Guenther <rguenther@suse.de> 2011-11-03 Richard Guenther <rguenther@suse.de>
PR middle-end/50079 PR middle-end/50079

View File

@ -0,0 +1,23 @@
! { dg-do compile }
! { dg-options "-O" }
! { dg-final { scan-assembler-not "i_am_optimized_away" } }
!
! PR fortran/50960
!
! PARAMETER arrays and derived types exists as static variables.
! Check that the their read-only nature is taken into account
! when optimizations are done.
!
module m
integer, parameter :: PARA(*) = [1,2,3,4,5,6,7,8,9,10]
end module m
subroutine test()
use m
integer :: i
i = 1
if (para(i) /= 1) call i_am_optimized_away()
end
! { dg-final { cleanup-modules "m" } }