+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>
* trans.h (struct gfc_ss, struct gfc_ss_info): Move field
/* If it wasn't used we wouldn't be getting it. */
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()
because this would add them to the current scope rather than the
function scope. */
+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>
PR middle-end/50079
--- /dev/null
+! { 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" } }