This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[gfortran] Fix nr 8 from PR 16404
- From: Tobias Schlüter <tobias dot schlueter at physik dot uni-muenchen dot de>
- To: GCC Fortran mailing list <fortran at gcc dot gnu dot org>,patch <gcc-patches at gcc dot gnu dot org>
- Date: Wed, 01 Sep 2004 00:07:02 +0200
- Subject: [gfortran] Fix nr 8 from PR 16404
Page 149, lines 6 and 7 have the following restriction on items being read or
written:
---
If a derived type ultimately contains a pointer component, an object of this
type shall not appear as an input item nor as the result of the evaluation of
an output item list item.
---
This was obviously missed when installing gfortran.dg/der_io_1.f90, which
tests that exactly this works. I suggest XFAILing this test with a dg-error,
and installing the patch appended below, which implements this restriction,
and which took me only a few seconds of copy and pasting from some other code
copyrighted by the FSF, and a few cleanups.
Built and tested, ok?
- Tobi
2004-08-31 Tobias Schlueter <tobias.schlueter@physik.uni-muenchen.de>
(port from g95)
* resolve.c (resolve_transfer): New function.
(resolve_code): Call resolve_transfer in case of EXEC_TRANSFER.
Index: resolve.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/fortran/resolve.c,v
retrieving revision 1.16
diff -u -p -r1.16 resolve.c
--- resolve.c 27 Aug 2004 14:49:34 -0000 1.16
+++ resolve.c 31 Aug 2004 21:56:54 -0000
@@ -2962,6 +2962,40 @@ resolve_select (gfc_code * code)
}
+/* Resolve a transfer statement. This is mainly just making sure that
+ a derived type being transferred has only non-pointer components. */
+
+static try
+resolve_transfer (gfc_code * code)
+{
+ gfc_typespec *typespec;
+ gfc_symbol *sym;
+ gfc_ref *ref;
+
+ if (code->expr->expr_type != EXPR_VARIABLE)
+ return SUCCESS;
+
+ sym = code->expr->symtree->n.sym;
+ typespec = &sym->ts;
+
+ /* Go to actual component transferred. */
+ for (ref = code->expr->ref; ref; ref = ref->next)
+ if (ref->type == REF_COMPONENT)
+ typespec = &ref->u.c.component->ts;
+
+ /* Check that transferred derived type doesn't contain POINTER
+ components. */
+ if (typespec->type == BT_DERIVED && derived_pointer (typespec->derived))
+ {
+ gfc_error ("Data transfer element at %L cannot have POINTER components",
+ &code->loc);
+ return FAILURE;
+ }
+
+ return SUCCESS;
+}
+
+
/*********** Toplevel code resolution subroutines ***********/
/* Given a branch to a label and a namespace, if the branch is conforming.
@@ -3568,7 +3602,6 @@ resolve_code (gfc_code * code, gfc_names
case EXEC_EXIT:
case EXEC_CONTINUE:
case EXEC_DT_END:
- case EXEC_TRANSFER:
case EXEC_ENTRY:
break;
@@ -3754,6 +3787,10 @@ resolve_code (gfc_code * code, gfc_names
resolve_branch (code->ext.dt->eor, code);
break;
+ case EXEC_TRANSFER:
+ resolve_transfer (code);
+ break;
+
case EXEC_FORALL:
resolve_forall_iterators (code->ext.forall_iterator);