re PR fortran/47745 ([OOP] Segfault with CLASS(*) and derived type dummy arguments)
2011-02-16 Janus Weil <janus@gcc.gnu.org> PR fortran/47745 * class.c (gfc_build_class_symbol): Set 'class_ok' attribute. * decl.c (build_sym,attr_decl1): Move setting of 'class_ok' into 'gfc_build_class_symbol'. (gfc_match_decl_type_spec): Reject unlimited polymorphism. * interface.c (matching_typebound_op): Check for 'class_ok' attribute. * match.c (select_type_set_tmp): Move setting of 'class_ok' into 'gfc_build_class_symbol'. * primary.c (gfc_variable_attr): Check for 'class_ok' attribute. 2011-02-16 Janus Weil <janus@gcc.gnu.org> PR fortran/47745 * gfortran.dg/class_39.f03: New. From-SVN: r170223
This commit is contained in:
parent
ebcb4bc304
commit
528622fd85
@ -1,3 +1,15 @@
|
|||||||
|
2011-02-16 Janus Weil <janus@gcc.gnu.org>
|
||||||
|
|
||||||
|
PR fortran/47745
|
||||||
|
* class.c (gfc_build_class_symbol): Set 'class_ok' attribute.
|
||||||
|
* decl.c (build_sym,attr_decl1): Move setting of 'class_ok' into
|
||||||
|
'gfc_build_class_symbol'.
|
||||||
|
(gfc_match_decl_type_spec): Reject unlimited polymorphism.
|
||||||
|
* interface.c (matching_typebound_op): Check for 'class_ok' attribute.
|
||||||
|
* match.c (select_type_set_tmp): Move setting of 'class_ok' into
|
||||||
|
'gfc_build_class_symbol'.
|
||||||
|
* primary.c (gfc_variable_attr): Check for 'class_ok' attribute.
|
||||||
|
|
||||||
2011-02-15 Steven G. Kargl <kargl@gcc.gnu.org>
|
2011-02-15 Steven G. Kargl <kargl@gcc.gnu.org>
|
||||||
|
|
||||||
PR fortran/47633
|
PR fortran/47633
|
||||||
|
@ -183,6 +183,16 @@ gfc_build_class_symbol (gfc_typespec *ts, symbol_attribute *attr,
|
|||||||
gfc_symbol *fclass;
|
gfc_symbol *fclass;
|
||||||
gfc_symbol *vtab;
|
gfc_symbol *vtab;
|
||||||
gfc_component *c;
|
gfc_component *c;
|
||||||
|
|
||||||
|
if (attr->class_ok)
|
||||||
|
/* Class container has already been built. */
|
||||||
|
return SUCCESS;
|
||||||
|
|
||||||
|
attr->class_ok = attr->dummy || attr->pointer || attr->allocatable;
|
||||||
|
|
||||||
|
if (!attr->class_ok)
|
||||||
|
/* We can not build the class container yet. */
|
||||||
|
return SUCCESS;
|
||||||
|
|
||||||
if (*as)
|
if (*as)
|
||||||
{
|
{
|
||||||
|
@ -1177,9 +1177,7 @@ build_sym (const char *name, gfc_charlen *cl, bool cl_deferred,
|
|||||||
|
|
||||||
sym->attr.implied_index = 0;
|
sym->attr.implied_index = 0;
|
||||||
|
|
||||||
if (sym->ts.type == BT_CLASS
|
if (sym->ts.type == BT_CLASS)
|
||||||
&& (sym->attr.class_ok = sym->attr.dummy || sym->attr.pointer
|
|
||||||
|| sym->attr.allocatable))
|
|
||||||
return gfc_build_class_symbol (&sym->ts, &sym->attr, &sym->as, false);
|
return gfc_build_class_symbol (&sym->ts, &sym->attr, &sym->as, false);
|
||||||
|
|
||||||
return SUCCESS;
|
return SUCCESS;
|
||||||
@ -2613,6 +2611,16 @@ gfc_match_decl_type_spec (gfc_typespec *ts, int implicit_flag)
|
|||||||
ts->type = BT_DERIVED;
|
ts->type = BT_DERIVED;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
/* Match CLASS declarations. */
|
||||||
|
m = gfc_match (" class ( * )");
|
||||||
|
if (m == MATCH_ERROR)
|
||||||
|
return MATCH_ERROR;
|
||||||
|
else if (m == MATCH_YES)
|
||||||
|
{
|
||||||
|
gfc_fatal_error ("Unlimited polymorphism at %C not yet supported");
|
||||||
|
return MATCH_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
m = gfc_match (" class ( %n )", name);
|
m = gfc_match (" class ( %n )", name);
|
||||||
if (m != MATCH_YES)
|
if (m != MATCH_YES)
|
||||||
return m;
|
return m;
|
||||||
@ -6045,9 +6053,7 @@ attr_decl1 (void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sym->ts.type == BT_CLASS && !sym->attr.class_ok
|
if (sym->ts.type == BT_CLASS
|
||||||
&& (sym->attr.class_ok = sym->attr.class_ok || current_attr.allocatable
|
|
||||||
|| current_attr.pointer)
|
|
||||||
&& gfc_build_class_symbol (&sym->ts, &sym->attr, &sym->as, false) == FAILURE)
|
&& gfc_build_class_symbol (&sym->ts, &sym->attr, &sym->as, false) == FAILURE)
|
||||||
{
|
{
|
||||||
m = MATCH_ERROR;
|
m = MATCH_ERROR;
|
||||||
|
@ -2924,7 +2924,11 @@ matching_typebound_op (gfc_expr** tb_base,
|
|||||||
gfc_try result;
|
gfc_try result;
|
||||||
|
|
||||||
if (base->expr->ts.type == BT_CLASS)
|
if (base->expr->ts.type == BT_CLASS)
|
||||||
derived = CLASS_DATA (base->expr)->ts.u.derived;
|
{
|
||||||
|
if (!gfc_expr_attr (base->expr).class_ok)
|
||||||
|
continue;
|
||||||
|
derived = CLASS_DATA (base->expr)->ts.u.derived;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
derived = base->expr->ts.u.derived;
|
derived = base->expr->ts.u.derived;
|
||||||
|
|
||||||
|
@ -4536,11 +4536,8 @@ select_type_set_tmp (gfc_typespec *ts)
|
|||||||
gfc_add_pointer (&tmp->n.sym->attr, NULL);
|
gfc_add_pointer (&tmp->n.sym->attr, NULL);
|
||||||
gfc_add_flavor (&tmp->n.sym->attr, FL_VARIABLE, name, NULL);
|
gfc_add_flavor (&tmp->n.sym->attr, FL_VARIABLE, name, NULL);
|
||||||
if (ts->type == BT_CLASS)
|
if (ts->type == BT_CLASS)
|
||||||
{
|
gfc_build_class_symbol (&tmp->n.sym->ts, &tmp->n.sym->attr,
|
||||||
gfc_build_class_symbol (&tmp->n.sym->ts, &tmp->n.sym->attr,
|
&tmp->n.sym->as, false);
|
||||||
&tmp->n.sym->as, false);
|
|
||||||
tmp->n.sym->attr.class_ok = 1;
|
|
||||||
}
|
|
||||||
tmp->n.sym->attr.select_type_temporary = 1;
|
tmp->n.sym->attr.select_type_temporary = 1;
|
||||||
|
|
||||||
/* Add an association for it, so the rest of the parser knows it is
|
/* Add an association for it, so the rest of the parser knows it is
|
||||||
|
@ -2033,7 +2033,7 @@ gfc_variable_attr (gfc_expr *expr, gfc_typespec *ts)
|
|||||||
sym = expr->symtree->n.sym;
|
sym = expr->symtree->n.sym;
|
||||||
attr = sym->attr;
|
attr = sym->attr;
|
||||||
|
|
||||||
if (sym->ts.type == BT_CLASS)
|
if (sym->ts.type == BT_CLASS && sym->attr.class_ok)
|
||||||
{
|
{
|
||||||
dimension = CLASS_DATA (sym)->attr.dimension;
|
dimension = CLASS_DATA (sym)->attr.dimension;
|
||||||
pointer = CLASS_DATA (sym)->attr.class_pointer;
|
pointer = CLASS_DATA (sym)->attr.class_pointer;
|
||||||
|
@ -1,3 +1,8 @@
|
|||||||
|
2011-02-16 Janus Weil <janus@gcc.gnu.org>
|
||||||
|
|
||||||
|
PR fortran/47745
|
||||||
|
* gfortran.dg/class_39.f03: New.
|
||||||
|
|
||||||
2011-02-16 Dodji Seketeli <dodji@redhat.com>
|
2011-02-16 Dodji Seketeli <dodji@redhat.com>
|
||||||
|
|
||||||
PR c++/47326
|
PR c++/47326
|
||||||
|
13
gcc/testsuite/gfortran.dg/class_39.f03
Normal file
13
gcc/testsuite/gfortran.dg/class_39.f03
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
! { dg-do compile }
|
||||||
|
!
|
||||||
|
! PR 47745: [OOP] Segfault with CLASS(*) and derived type dummy arguments
|
||||||
|
!
|
||||||
|
! Contributed by Rodney Polkinghorne <thisrod@gmail.com>
|
||||||
|
|
||||||
|
type, abstract :: T
|
||||||
|
end type T
|
||||||
|
contains
|
||||||
|
class(T) function add() ! { dg-error "must be dummy, allocatable or pointer" }
|
||||||
|
add = 1 ! { dg-error "Variable must not be polymorphic in assignment" }
|
||||||
|
end function
|
||||||
|
end
|
Loading…
x
Reference in New Issue
Block a user