Commit 22c30bc0 by Tobias Burnus Committed by Tobias Burnus

re PR fortran/51809 ([OOP] ICE (segfault) depending on USE statements order)

2012-01-16  Tobias Burnus  <burnus@net-b.de>

        PR fortran/51809
        * class.c (gfc_find_derived_vtab): Mark __vtab and
        __def_init as FL_VARIABLE not as FL_PARAMETER.
        * expr.c (gfc_simplify_expr): Remove special
        handling of __vtab.
        * resolve.c (resolve_values): Ditto.
        * trans-decl.c (gfc_get_symbol_decl): Mark __vtab
        and __def_init as TREE_READONLY.

2012-01-16  Tobias Burnus  <burnus@net-b.de>

        PR fortran/51809
        * gfortran.dg/use_20.f90: New

From-SVN: r183219
parent 645c7a55
2012-01-16 Tobias Burnus <burnus@net-b.de>
PR fortran/51809
* class.c (gfc_find_derived_vtab): Mark __vtab and
__def_init as FL_VARIABLE not as FL_PARAMETER.
* expr.c (gfc_simplify_expr): Remove special
handling of __vtab.
* resolve.c (resolve_values): Ditto.
* trans-decl.c (gfc_get_symbol_decl): Mark __vtab
and __def_init as TREE_READONLY.
2012-01-16 Paul Thomas <pault@gcc.gnu.org> 2012-01-16 Paul Thomas <pault@gcc.gnu.org>
* trans-array.c (gfc_trans_create_temp_array): In the case of a * trans-array.c (gfc_trans_create_temp_array): In the case of a
......
...@@ -588,7 +588,7 @@ gfc_find_derived_vtab (gfc_symbol *derived) ...@@ -588,7 +588,7 @@ gfc_find_derived_vtab (gfc_symbol *derived)
{ {
gfc_get_symbol (name, ns, &vtab); gfc_get_symbol (name, ns, &vtab);
vtab->ts.type = BT_DERIVED; vtab->ts.type = BT_DERIVED;
if (gfc_add_flavor (&vtab->attr, FL_PARAMETER, NULL, if (gfc_add_flavor (&vtab->attr, FL_VARIABLE, NULL,
&gfc_current_locus) == FAILURE) &gfc_current_locus) == FAILURE)
goto cleanup; goto cleanup;
vtab->attr.target = 1; vtab->attr.target = 1;
...@@ -682,7 +682,7 @@ gfc_find_derived_vtab (gfc_symbol *derived) ...@@ -682,7 +682,7 @@ gfc_find_derived_vtab (gfc_symbol *derived)
def_init->attr.target = 1; def_init->attr.target = 1;
def_init->attr.save = SAVE_IMPLICIT; def_init->attr.save = SAVE_IMPLICIT;
def_init->attr.access = ACCESS_PUBLIC; def_init->attr.access = ACCESS_PUBLIC;
def_init->attr.flavor = FL_PARAMETER; def_init->attr.flavor = FL_VARIABLE;
gfc_set_sym_referenced (def_init); gfc_set_sym_referenced (def_init);
def_init->ts.type = BT_DERIVED; def_init->ts.type = BT_DERIVED;
def_init->ts.u.derived = derived; def_init->ts.u.derived = derived;
......
...@@ -1883,8 +1883,7 @@ gfc_simplify_expr (gfc_expr *p, int type) ...@@ -1883,8 +1883,7 @@ gfc_simplify_expr (gfc_expr *p, int type)
initialization expression, or we want a subsection. */ initialization expression, or we want a subsection. */
if (p->symtree->n.sym->attr.flavor == FL_PARAMETER if (p->symtree->n.sym->attr.flavor == FL_PARAMETER
&& (gfc_init_expr_flag || p->ref && (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) if (simplify_parameter_variable (p, type) == FAILURE)
return FAILURE; return FAILURE;
......
...@@ -9637,7 +9637,7 @@ resolve_values (gfc_symbol *sym) ...@@ -9637,7 +9637,7 @@ resolve_values (gfc_symbol *sym)
{ {
gfc_try t; gfc_try t;
if (sym->value == NULL || sym->attr.use_assoc) if (sym->value == NULL)
return; return;
if (sym->value->expr_type == EXPR_STRUCTURE) if (sym->value->expr_type == EXPR_STRUCTURE)
...@@ -12195,7 +12195,7 @@ resolve_fl_parameter (gfc_symbol *sym) ...@@ -12195,7 +12195,7 @@ resolve_fl_parameter (gfc_symbol *sym)
/* Make sure the types of derived parameters are consistent. This /* Make sure the types of derived parameters are consistent. This
type checking is deferred until resolution because the type may type checking is deferred until resolution because the type may
refer to a derived type from the host. */ refer to a derived type from the host. */
if (sym->ts.type == BT_DERIVED && sym->value if (sym->ts.type == BT_DERIVED
&& !gfc_compare_types (&sym->ts, &sym->value->ts)) && !gfc_compare_types (&sym->ts, &sym->value->ts))
{ {
gfc_error ("Incompatible derived type in PARAMETER at %L", gfc_error ("Incompatible derived type in PARAMETER at %L",
......
...@@ -1485,7 +1485,10 @@ gfc_get_symbol_decl (gfc_symbol * sym) ...@@ -1485,7 +1485,10 @@ gfc_get_symbol_decl (gfc_symbol * sym)
if (sym->attr.vtab if (sym->attr.vtab
|| (sym->name[0] == '_' && strncmp ("__def_init", sym->name, 10) == 0)) || (sym->name[0] == '_' && strncmp ("__def_init", sym->name, 10) == 0))
GFC_DECL_PUSH_TOPLEVEL (decl) = 1; {
TREE_READONLY (decl) = 1;
GFC_DECL_PUSH_TOPLEVEL (decl) = 1;
}
return decl; return decl;
} }
......
2012-01-16 Tobias Burnus <burnus@net-b.de>
PR fortran/51809
* gfortran.dg/use_20.f90: New
2012-01-16 Jason Merrill <jason@redhat.com> 2012-01-16 Jason Merrill <jason@redhat.com>
PR c++/51868 PR c++/51868
......
! { dg-do compile }
!
! PR fortran/51809
!
! Contributed by Kacper Kowalik
!
module foo
implicit none
type foo_t
contains
procedure :: func_foo
end type foo_t
contains
subroutine func_foo(this)
implicit none
class(foo_t), intent(in) :: this
end subroutine func_foo
end module foo
module bar
use foo, only: foo_t
implicit none
type, extends(foo_t) :: bar_t
contains
procedure :: func_bar
end type bar_t
contains
subroutine func_bar(this)
use foo, only: foo_t ! <--- removing this line also fixes ICE
implicit none
class(bar_t), intent(in) :: this
end subroutine func_bar
end module bar
module merry_ICE
use foo, only: foo_t ! <------ change order to prevent ICE
use bar, only: bar_t ! <------ change order to prevent ICE
end module merry_ICE
! { dg-final { cleanup-modules "foo bar merry_ice" } }
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