Following invalid testcase yields and ICE with current trunk. > cat small.f90 type sysmtx_t type(ext_complex_t), allocatable :: S(:) ! Block scales end type sysmtx_t contains subroutine init (this, n, n_e, n_i, n_o) class(sysmtx_t), intent(out) :: this > gfortran small.f90 small.f90:2.40: type(ext_complex_t), allocatable :: S(:) ! Block scales 1 Error: Derived type at (1) has not been previously defined and so cannot appear in a derived type definition f951: internal compiler error: in generate_finalization_wrapper, at fortran/class.c:1521 0x54f091 generate_finalization_wrapper ../../gcc/gcc/fortran/class.c:1520 0x54f091 gfc_find_derived_vtab(gfc_symbol*) ../../gcc/gcc/fortran/class.c:2394 0x54fc82 gfc_build_class_symbol(gfc_typespec*, symbol_attribute*, gfc_array_spec**, bool)
The ICE has been introduced between revisions 198750 (2013-05-09) and 199418 (2013-05-29): r199409?
Failing is the following assert in generate_finalization_wrapper: /* If there is no new finalizer and no new allocatable, return with an expr to the ancestor's one. */ if (!expr_null_wrapper && !finalizable_comp && (!derived->f2k_derived || !derived->f2k_derived->finalizers)) { gcc_assert (ancestor_wrapper && ancestor_wrapper->ref == NULL && ancestor_wrapper->expr_type == EXPR_VARIABLE);
Slightly modified test case: type sysmtx_t type(ext_complex_t), allocatable :: S(:) end type contains subroutine init (this) class(sysmtx_t) :: this end subroutine end
Draft patch: Index: gcc/fortran/decl.c =================================================================== --- gcc/fortran/decl.c (revision 201331) +++ gcc/fortran/decl.c (working copy) @@ -4286,12 +4286,10 @@ gfc_match_data_decl (void) || current_ts.u.derived->attr.zero_comp)) goto ok; - /* Now we have an error, which we signal, and then fix up - because the knock-on is plain and simple confusing. */ gfc_error_now ("Derived type at %C has not been previously defined " "and so cannot appear in a derived type definition"); - current_attr.pointer = 1; - goto ok; + m = MATCH_ERROR; + goto cleanup; } ok:
(In reply to janus from comment #4) > Draft patch: ... seems to regtest cleanly.
For the record: The code that I'm proposing to remove in comment 4 has been added by Paul in r105913: http://gcc.gnu.org/viewcvs/gcc?view=revision&revision=105913
(In reply to janus from comment #6) > For the record: The code that I'm proposing to remove in comment 4 has been > added by Paul in r105913: For PR24158 (ice-on-invalid-code), which was on 2005-10-26.
At r206460, I don't see the ICE any more. Possibly is has been fixed by r206379 (for PR59589)? Can someone confirm that it's gone? The output I now get for comment 3 (with 4.8 and trunk) is as follows: $ gfortran-4.9 c3.f90 c3.f90:3.40: type(ext_complex_t), allocatable :: S(:) 1 Error: Derived type at (1) has not been previously defined and so cannot appear in a derived type definition c3.f90:3.45: type(ext_complex_t), allocatable :: S(:) 1 Error: The pointer component 's' of 'sysmtx_t' at (1) is a type that has not been declared c3.f90:3.45: type(ext_complex_t), allocatable :: S(:) 1 Error: The pointer component 's' of 'sysmtx_t' at (1) is a type that has not been declared c3.f90:3.45: type(ext_complex_t), allocatable :: S(:) 1 Error: The pointer component 's' of 'sysmtx_t' at (1) is a type that has not been declared The first error is perfectly ok, but the following three (about a 'pointer component') are bogus. They are indeed removed by the patch in comment 4, so I think applying that patch still makes sense.
(In reply to Tobias Burnus from comment #7) > > For the record: The code that I'm proposing to remove in comment 4 has been > > added by Paul in r105913: > > For PR24158 (ice-on-invalid-code), which was on 2005-10-26. Btw: The corresponding test cases are derived_recursion.f90 implicit_actual.f90 The patch does not change the diagnostics for these cases (in particular there is no 'confusing knock-on).
(In reply to janus from comment #8) > At r206460, I don't see the ICE any more. Possibly is has been fixed by > r206379 (for PR59589)? Can someone confirm that it's gone? Reverting r206379 brings back the ICE, so indeed this revision has fixed it apparently. So: The ICE regression is fixed and only the error-recovery problem of comment 8 persists.
Further reduced test case for the error recovery: type sysmtx_t type(ext_complex_t), allocatable :: S(:) end type end Trunk (and 4.4 - 4.8) yield: c3.f90:3.40: type(ext_complex_t), allocatable :: S(:) 1 Error: Derived type at (1) has not been previously defined and so cannot appear in a derived type definition c3.f90:3.45: type(ext_complex_t), allocatable :: S(:) 1 Error: The pointer component 's' of 'sysmtx_t' at (1) is a type that has not been declared With the patch in comment 4 the second error, which is bogus, is removed.
Author: janus Date: Sun Jan 12 11:08:31 2014 New Revision: 206564 URL: http://gcc.gnu.org/viewcvs?rev=206564&root=gcc&view=rev Log: 2014-01-12 Janus Weil <janus@gcc.gnu.org> PR fortran/58026 * decl.c (gfc_match_data_decl): Improve error recovery. 2014-01-12 Janus Weil <janus@gcc.gnu.org> PR fortran/58026 * gfortran.dg/alloc_comp_basics_6.f90: New. Added: trunk/gcc/testsuite/gfortran.dg/alloc_comp_basics_6.f90 Modified: trunk/gcc/fortran/ChangeLog trunk/gcc/fortran/decl.c trunk/gcc/testsuite/ChangeLog
(In reply to janus from comment #10) > So: The ICE regression is fixed and only the error-recovery problem of > comment 8 persists. ... which is fixed on 4.9 trunk by r206564. Closing.