[multiple changes]

2012-09-03  Alessandro Fanfarillo  <fanfarillo.gcc@gmail.com>
            Tobias Burnus  <burnus@net-b.de>

        PR fortran/37336
        * gfortran.h (symbol_attribute): Add artificial.
        * module.c (mio_symbol_attribute): Handle attr.artificial
        * class.c (gfc_build_class_symbol): Defer creation of the vtab
        if the DT has finalizers, mark generated symbols as
        attr.artificial.
        (has_finalizer_component, finalize_component,
        finalization_scalarizer, generate_finalization_wrapper):
        New static functions.
        (gfc_find_derived_vtab): Add _final component and call
        generate_finalization_wrapper.
        * dump-parse-tree.c (show_f2k_derived): Use resolved
        proc_tree->n.sym rather than unresolved proc_sym.
        (show_attr): Handle attr.artificial.
        * resolve.c (gfc_resolve_finalizers): Ensure that the vtab
        * exists.
        (resolve_fl_derived): Resolve finalizers before
        generating the vtab.
        (resolve_symbol): Also allow assumed-rank arrays with CONTIGUOUS;
        skip artificial symbols.
        (resolve_fl_derived0): Skip artificial symbols.

2012-09-03  Tobias Burnus  <burnus@net-b.de>

        PR fortran/51632
        * gfortran.dg/coarray_class_1.f90: New.

From-SVN: r190869
diff --git a/gcc/fortran/resolve.c b/gcc/fortran/resolve.c
index 312713b..28eea5d 100644
--- a/gcc/fortran/resolve.c
+++ b/gcc/fortran/resolve.c
@@ -11222,6 +11222,7 @@
   gfc_error ("Finalization at %L is not yet implemented",
 	     &derived->declared_at);
 
+  gfc_find_derived_vtab (derived);
   return result;
 }
 
@@ -11925,6 +11926,9 @@
 
   for ( ; c != NULL; c = c->next)
     {
+      if (c->attr.artificial)
+	continue;
+
       /* See PRs 51550, 47545, 48654, 49050, 51075 - and 45170.  */
       if (c->ts.type == BT_CHARACTER && c->ts.deferred && !c->attr.function)
 	{
@@ -12321,6 +12325,10 @@
 			 &sym->declared_at) == FAILURE)
     return FAILURE;
 
+  /* Resolve the finalizer procedures.  */
+  if (gfc_resolve_finalizers (sym) == FAILURE)
+    return FAILURE;
+  
   if (sym->attr.is_class && sym->ts.u.derived == NULL)
     {
       /* Fix up incomplete CLASS symbols.  */
@@ -12341,10 +12349,6 @@
   if (resolve_typebound_procedures (sym) == FAILURE)
     return FAILURE;
 
-  /* Resolve the finalizer procedures.  */
-  if (gfc_resolve_finalizers (sym) == FAILURE)
-    return FAILURE;
-  
   return SUCCESS;
 }
 
@@ -12541,6 +12545,9 @@
   symbol_attribute class_attr;
   gfc_array_spec *as;
 
+  if (sym->attr.artificial)
+    return;
+
   if (sym->attr.flavor == FL_UNKNOWN
       || (sym->attr.flavor == FL_PROCEDURE && !sym->attr.intrinsic
 	  && !sym->attr.generic && !sym->attr.external
@@ -12674,11 +12681,12 @@
   /* F2008, C530. */
   if (sym->attr.contiguous
       && (!class_attr.dimension
-	  || (as->type != AS_ASSUMED_SHAPE && !class_attr.pointer)))
+	  || (as->type != AS_ASSUMED_SHAPE && as->type != AS_ASSUMED_RANK
+	      && !class_attr.pointer)))
     {
       gfc_error ("'%s' at %L has the CONTIGUOUS attribute but is not an "
-		  "array pointer or an assumed-shape array", sym->name,
-		  &sym->declared_at);
+		 "array pointer or an assumed-shape or assumed-rank array",
+		 sym->name, &sym->declared_at);
       return;
     }