The following program compiles with GCC 4.5 and ifort, but fails with GCC 4.6 and GCC 4.7 with: if(allocated(x)) stop 1 Error: 'array' argument of 'allocated' intrinsic at (1) must be ALLOCATABLE module m type t end type t class(t), allocatable :: x end module m use m implicit none if(allocated(x)) stop end
I think the problem is that the 'class_ok' attribute is not set when loading the symbol from the module.
Here's an attempt to fix it: Index: module.c =================================================================== --- module.c (revision 179566) +++ module.c (working copy) @@ -3608,6 +3608,8 @@ mio_symbol (gfc_symbol *sym) mio_symbol_attribute (&sym->attr); mio_typespec (&sym->ts); + if (sym->ts.type == BT_CLASS) + sym->attr.class_ok = 1; if (iomode == IO_OUTPUT) mio_namespace_ref (&sym->formal_ns); A similar thing is already being done for components (cf. 'mio_component'). However, with this patch, the test case gives me a different error: internal compiler error: in gfc_conv_component_ref, at fortran/trans-expr.c:529
(In reply to comment #2) > However, with this patch, the test case gives me a different error: > > internal compiler error: in gfc_conv_component_ref, at fortran/trans-expr.c:529 ... which is: gcc_assert (c->backend_decl); I have no idea why the backend_decl is missing, though. Otherwise the patch regtests cleanly.
(In reply to comment #2) > However, with this patch, the test case gives me a different error: > > internal compiler error: in gfc_conv_component_ref, at fortran/trans-expr.c:529 This can be fixed with an additional patchlet: Index: gcc/fortran/trans-decl.c =================================================================== --- gcc/fortran/trans-decl.c (revision 179592) +++ gcc/fortran/trans-decl.c (working copy) @@ -1179,7 +1179,10 @@ gfc_get_symbol_decl (gfc_symbol * sym) { gfc_component *c = CLASS_DATA (sym); if (!c->ts.u.derived->backend_decl) - gfc_find_derived_vtab (c->ts.u.derived); + { + gfc_find_derived_vtab (c->ts.u.derived); + gfc_get_derived_type (sym->ts.u.derived); + } } /* All deferred character length procedures need to retain the backend
Author: janus Date: Fri Oct 7 14:40:14 2011 New Revision: 179660 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=179660 Log: 2011-10-07 Janus Weil <janus@gcc.gnu.org> PR fortran/50625 * class.c (gfc_build_class_symbol): Fix whitespace. * module.c (mio_symbol): Set 'class_ok' attribute. * trans-decl.c (gfc_get_symbol_decl): Make sure the backend_decl has been built for class symbols. 2011-10-07 Janus Weil <janus@gcc.gnu.org> PR fortran/50625 * gfortran.dg/class_46.f03: New. Added: trunk/gcc/testsuite/gfortran.dg/class_46.f03 Modified: trunk/gcc/fortran/ChangeLog trunk/gcc/fortran/class.c trunk/gcc/fortran/module.c trunk/gcc/fortran/trans-decl.c trunk/gcc/testsuite/ChangeLog
Fixed on trunk with r179660.
Author: janus Date: Fri Oct 7 21:01:02 2011 New Revision: 179696 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=179696 Log: 2011-10-07 Janus Weil <janus@gcc.gnu.org> PR fortran/50585 * interface.c (get_expr_storage_size): Check if 'length' component is associated. PR fortran/50625 * class.c (gfc_build_class_symbol): Fix whitespace. * module.c (mio_symbol): Set 'class_ok' attribute. * trans-decl.c (gfc_get_symbol_decl): Make sure the backend_decl has been built for class symbols. 2011-10-07 Janus Weil <janus@gcc.gnu.org> PR fortran/50585 * gfortran.dg/assumed_charlen_arg_2.f90: New. PR fortran/50625 * gfortran.dg/class_46.f03: New. Added: branches/gcc-4_6-branch/gcc/testsuite/gfortran.dg/assumed_charlen_arg_2.f90 branches/gcc-4_6-branch/gcc/testsuite/gfortran.dg/class_46.f03 Modified: branches/gcc-4_6-branch/gcc/fortran/ChangeLog branches/gcc-4_6-branch/gcc/fortran/class.c branches/gcc-4_6-branch/gcc/fortran/interface.c branches/gcc-4_6-branch/gcc/fortran/module.c branches/gcc-4_6-branch/gcc/fortran/trans-decl.c branches/gcc-4_6-branch/gcc/testsuite/ChangeLog
Fixed on trunk and 4.6. Closing.