This is the mail archive of the gcc-bugs@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]

[Bug fortran/44556] incorrect error: Stat-variable at (1) shall not be DEALLOCATEd within the same DEALLOCATE statement



------- Comment #7 from kargl at gcc dot gnu dot org  2010-06-17 19:08 -------
The following patch restores the 4.4.0 behavior for
STAT of not checking derived type components.  This
of course now allows invalid code to compile such as
this modified version of OP's test subroutine

   subroutine test
      type(test_type) :: foo
      deallocate(foo%array, stat=foo%array(1))
   end subroutine test


Index: resolve.c
===================================================================
--- resolve.c   (revision 160935)
+++ resolve.c   (working copy)
@@ -6588,7 +6588,8 @@ resolve_allocate_deallocate (gfc_code *c
                   "variable", &stat->where);

       for (p = code->ext.alloc.list; p; p = p->next)
-       if (p->expr->symtree->n.sym->name == stat->symtree->n.sym->name)
+       if (stat->symtree->n.sym->ts.type != BT_DERIVED
+           && p->expr->symtree->n.sym->name == stat->symtree->n.sym->name)
          gfc_error ("Stat-variable at %L shall not be %sd within "
                     "the same %s statement", &stat->where, fcn, fcn);
     }
@@ -6617,7 +6618,8 @@ resolve_allocate_deallocate (gfc_code *c
                   "variable", &errmsg->where);

       for (p = code->ext.alloc.list; p; p = p->next)
-       if (p->expr->symtree->n.sym->name == errmsg->symtree->n.sym->name)
+       if (errmsg->symtree->n.sym->ts.type != BT_DERIVED
+           && p->expr->symtree->n.sym->name == errmsg->symtree->n.sym->name)
          gfc_error ("Errmsg-variable at %L shall not be %sd within "
                     "the same %s statement", &errmsg->where, fcn, fcn);
     }


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44556


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