Hi all,
the attached patch marks the 'vtab' symbols as constant
(FL_PARAMETER). They are fixed objects which are initialized once and
never change.
Regtested on x86_64-unknown-linux-gnu. Ok for trunk?
Is it ok to commit without a test case? If not, any suggestions how a
good test case could look like?
Cheers,
Janus
2011-11-08 Janus Weil <[email protected]>
PR fortran/50960
* class.c (gfc_find_derived_vtab): Make the vtab symbols FL_PARAMETER.
* expr.c (gfc_simplify_expr): Prevent vtabs from being replaced with
their value.
* resolve.c (resolve_values): Use-associated symbols do not need to
be resolved again.
(resolve_fl_parameter): Make sure the symbol has a value.
Index: gcc/fortran/class.c
===================================================================
--- gcc/fortran/class.c (revision 181107)
+++ gcc/fortran/class.c (working copy)
@@ -428,7 +428,7 @@ gfc_find_derived_vtab (gfc_symbol *derived)
{
gfc_get_symbol (name, ns, &vtab);
vtab->ts.type = BT_DERIVED;
- if (gfc_add_flavor (&vtab->attr, FL_VARIABLE, NULL,
+ if (gfc_add_flavor (&vtab->attr, FL_PARAMETER, NULL,
&gfc_current_locus) == FAILURE)
goto cleanup;
vtab->attr.target = 1;
Index: gcc/fortran/expr.c
===================================================================
--- gcc/fortran/expr.c (revision 181106)
+++ gcc/fortran/expr.c (working copy)
@@ -1883,7 +1883,8 @@ gfc_simplify_expr (gfc_expr *p, int type)
initialization expression, or we want a subsection. */
if (p->symtree->n.sym->attr.flavor == FL_PARAMETER
&& (gfc_init_expr_flag || p->ref
- || p->symtree->n.sym->value->expr_type != EXPR_ARRAY))
+ || p->symtree->n.sym->value->expr_type != EXPR_ARRAY)
+ && !p->symtree->n.sym->attr.vtab)
{
if (simplify_parameter_variable (p, type) == FAILURE)
return FAILURE;
Index: gcc/fortran/resolve.c
===================================================================
--- gcc/fortran/resolve.c (revision 181107)
+++ gcc/fortran/resolve.c (working copy)
@@ -9514,7 +9514,7 @@ resolve_values (gfc_symbol *sym)
{
gfc_try t;
- if (sym->value == NULL)
+ if (sym->value == NULL || sym->attr.use_assoc)
return;
if (sym->value->expr_type == EXPR_STRUCTURE)
@@ -11982,7 +11982,7 @@ resolve_fl_parameter (gfc_symbol *sym)
/* Make sure the types of derived parameters are consistent. This
type checking is deferred until resolution because the type may
refer to a derived type from the host. */
- if (sym->ts.type == BT_DERIVED
+ if (sym->ts.type == BT_DERIVED && sym->value
&& !gfc_compare_types (&sym->ts, &sym->value->ts))
{
gfc_error ("Incompatible derived type in PARAMETER at %L",