[Bug fortran/86551] [OOP] ICE on invalid code with select type
janus at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Sun Sep 16 12:22:00 GMT 2018
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86551
--- Comment #4 from janus at gcc dot gnu.org ---
The patch in comment #3 shows lots of regressions in the testsuite, but this
one should be better:
diff --git a/gcc/fortran/match.c b/gcc/fortran/match.c
index 85247dd8334..6cf816be511 100644
--- a/gcc/fortran/match.c
+++ b/gcc/fortran/match.c
@@ -6009,7 +6009,7 @@ copy_ts_from_selector_to_associate (gfc_expr *associate,
gfc_expr *selector)
else
assoc_sym->as = NULL;
- if (selector->ts.type == BT_CLASS)
+ if (selector->ts.type == BT_CLASS && gfc_expr_attr (selector).class_ok)
{
/* The correct class container has to be available. */
assoc_sym->ts.type = BT_CLASS;
diff --git a/gcc/fortran/resolve.c b/gcc/fortran/resolve.c
index ea0ce800743..67b625f3a51 100644
--- a/gcc/fortran/resolve.c
+++ b/gcc/fortran/resolve.c
@@ -8867,6 +8867,9 @@ resolve_select_type (gfc_code *code, gfc_namespace
*old_ns)
if (code->expr2)
{
+ if (!gfc_expr_attr (code->expr2).class_ok)
+ return;
+
if (code->expr1->symtree->n.sym->attr.untyped)
code->expr1->symtree->n.sym->ts = code->expr2->ts;
selector_type = CLASS_DATA (code->expr2)->ts.u.derived;
Unfortunately it still fails on:
FAIL: gfortran.dg/allocate_with_source_15.f03 -Os (internal compiler error)
FAIL: gfortran.dg/select_type_26.f03 -O0 (internal compiler error)
FAIL: gfortran.dg/select_type_27.f03 -O0 (internal compiler error)
More information about the Gcc-bugs
mailing list