From: Paul Thomas Date: Wed, 13 Mar 2013 06:36:02 +0000 (+0000) Subject: re PR fortran/56575 (An invalid OO code causes ICE) X-Git-Tag: releases/gcc-4.6.4~107 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=679376b4a16e9374c5bb87fa4efb6cc81beb3a42;p=thirdparty%2Fgcc.git re PR fortran/56575 (An invalid OO code causes ICE) 2013-03-13 Paul Thomas PR fortran/56575 * expr.c (gfc_default_initializer): Check that a class declared type has any components. * resolve.c (resolve_fl_derived0): On failing the test for C437 set the type to BT_UNKNOWN to prevent repeat error messages. 2013-03-13 Paul Thomas PR fortran/56575 * gfortran.dg/class_56.f90: New test. From-SVN: r196628 --- diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 728c8e93e1ea..6cf6aa6ca44d 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,11 @@ +2013-03-13 Paul Thomas + + PR fortran/56575 + * expr.c (gfc_default_initializer): Check that a class declared + type has any components. + * resolve.c (resolve_fl_derived0): On failing the test for C437 + set the type to BT_UNKNOWN to prevent repeat error messages. + 2013-03-10 Paul Thomas PR fortran/55362 diff --git a/gcc/fortran/expr.c b/gcc/fortran/expr.c index 8fa542e80792..5fa937e85461 100644 --- a/gcc/fortran/expr.c +++ b/gcc/fortran/expr.c @@ -3704,7 +3704,8 @@ gfc_default_initializer (gfc_typespec *ts) types (otherwise we could use gfc_has_default_initializer()). */ for (comp = ts->u.derived->components; comp; comp = comp->next) if (comp->initializer || comp->attr.allocatable - || (comp->ts.type == BT_CLASS && CLASS_DATA (comp)->attr.allocatable)) + || (comp->ts.type == BT_CLASS && CLASS_DATA (comp) + && CLASS_DATA (comp)->attr.allocatable)) break; if (!comp) diff --git a/gcc/fortran/resolve.c b/gcc/fortran/resolve.c index ae6e8cedbb93..9ba9455aff90 100644 --- a/gcc/fortran/resolve.c +++ b/gcc/fortran/resolve.c @@ -11759,6 +11759,8 @@ resolve_fl_derived0 (gfc_symbol *sym) { gfc_error ("Component '%s' with CLASS at %L must be allocatable " "or pointer", c->name, &c->loc); + /* Prevent a recurrence of the error. */ + c->ts.type = BT_UNKNOWN; return FAILURE; } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 1bda4549af1d..401c1ed54a63 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2013-03-13 Paul Thomas + + PR fortran/56575 + * gfortran.dg/class_56.f90: New test. + 2013-03-10 Paul Thomas PR fortran/55362