This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Patch, Fortran, OOP] PR 50625: [4.6/4.7 Regression] ALLOCATABLE attribute lost for module CLASS variables


Hi all,

here is a small patch for an OOP regression. The title of the PR is a
bit misleading, since it's actually not the ALLOCATABLE attribute
which gets lost, but the 'class_ok' attribute, which we use for
checking if a class declaration is valid. When reading class variables
from a module, we can just set this attribute to '1' (if there was an
error, it would have been caught earlier).

Moreover there was a slight problem with backend_decl's not being
present for class symbols, which is being fixed by the hunk in
trans-decl.c.

Regtested successfully on x86_64-unknown-linux-gnu (except for failure
on entry_4 and select_type_12, which are known middle-end
regressions). Ok for trunk and 4.6?

Cheers,
Janus


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.
Index: gcc/fortran/class.c
===================================================================
--- gcc/fortran/class.c	(revision 179647)
+++ gcc/fortran/class.c	(working copy)
@@ -188,7 +188,7 @@ gfc_build_class_symbol (gfc_typespec *ts, symbol_a
     /* Class container has already been built.  */
     return SUCCESS;
 
-  attr->class_ok = attr->dummy || attr->pointer  || attr->allocatable;
+  attr->class_ok = attr->dummy || attr->pointer || attr->allocatable;
   
   if (!attr->class_ok)
     /* We can not build the class container yet.  */
Index: gcc/fortran/module.c
===================================================================
--- gcc/fortran/module.c	(revision 179647)
+++ gcc/fortran/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);
Index: gcc/fortran/trans-decl.c
===================================================================
--- gcc/fortran/trans-decl.c	(revision 179647)
+++ 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

Attachment: class_46.f03
Description: Binary data


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]