re PR fortran/50625 ([OOP] ALLOCATABLE attribute lost for module CLASS variables)
authorJanus Weil <janus@gcc.gnu.org>
Fri, 7 Oct 2011 14:40:14 +0000 (16:40 +0200)
committerJanus Weil <janus@gcc.gnu.org>
Fri, 7 Oct 2011 14:40:14 +0000 (16:40 +0200)
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.

From-SVN: r179660

gcc/fortran/ChangeLog
gcc/fortran/class.c
gcc/fortran/module.c
gcc/fortran/trans-decl.c
gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.dg/class_46.f03 [new file with mode: 0644]

index 23053c41ae433f43ea6d6b18c25c49518de285f1..f5fc071f7e419ddd304a56562d0e0b06b75d82e9 100644 (file)
@@ -1,3 +1,11 @@
+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-04  Janus Weil  <janus@gcc.gnu.org>
 
        PR fortran/35831
index 572011f45f6af951a54bb13fa711fda3086699bc..f64cc1b2a810b72e8ef3600dd8a4e5efe88486d1 100644 (file)
@@ -188,7 +188,7 @@ gfc_build_class_symbol (gfc_typespec *ts, symbol_attribute *attr,
     /* 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 b29ba4b66ee1f4634eb457d731e34865141619cc..c8a377d2165755b9465e4f98e6259e1dd1f6c39d 100644 (file)
@@ -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 44363c298ae083e5ddbf3b79e77d52be1ede4739..4526aaabb3ac2339507cdc23cbd7f3349983be17 100644 (file)
@@ -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
index 92ae8b340a9ff724e30637726223186b1f3fcace..af8d1643a22d2b676193d7acb302685b95028ea4 100644 (file)
@@ -1,3 +1,8 @@
+2011-10-07  Janus Weil  <janus@gcc.gnu.org>
+
+       PR fortran/50625
+       * gfortran.dg/class_46.f03: New.
+
 2011-10-06  Joern Rennecke <joern.rennecke@embecosm.com>
 
        * gcc.dg/pr47276.c (ASMNAME, ASMNAME2, STRING): Define.
diff --git a/gcc/testsuite/gfortran.dg/class_46.f03 b/gcc/testsuite/gfortran.dg/class_46.f03
new file mode 100644 (file)
index 0000000..4719c25
--- /dev/null
@@ -0,0 +1,18 @@
+! { dg-do run }
+!
+! PR 50625: [4.6/4.7 Regression][OOP] ALLOCATABLE attribute lost for module CLASS variables
+!
+! Contributed by Tobias Burnus <burnus@gcc.gnu.org>
+
+module m
+type t
+end type t
+class(t), allocatable :: x
+end module m
+
+use m
+implicit none
+if (allocated(x)) call abort()
+end 
+
+! { dg-final { cleanup-modules "m" } }