summaryrefslogtreecommitdiff
path: root/libgfortran
diff options
context:
space:
mode:
authorjvdelisle <jvdelisle@138bc75d-0d04-0410-961f-82ee72b054a4>2008-01-25 23:34:53 +0000
committerjvdelisle <jvdelisle@138bc75d-0d04-0410-961f-82ee72b054a4>2008-01-25 23:34:53 +0000
commitbd91c586c5d227153f6bea1158194980545dca9e (patch)
tree0ddaf66a512f8044b2abcef9d3a0c3f7ad1631d1 /libgfortran
parent5a82d68e54b3d3377e5698942c3f3e1ef428941b (diff)
downloadgcc-bd91c586c5d227153f6bea1158194980545dca9e.tar.gz
2008-01-25 Jerry DeLisle <jvdelisle@gcc.gnu.org>
PR libfortran/34876 * io/transfer.c (write_buf): Handle case of zero sized array. (transfer_array): Set data pointer to NULL and size to zero. Then make a data transfer and return. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@131848 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libgfortran')
-rw-r--r--libgfortran/ChangeLog7
-rw-r--r--libgfortran/io/transfer.c19
2 files changed, 23 insertions, 3 deletions
diff --git a/libgfortran/ChangeLog b/libgfortran/ChangeLog
index 8ac8c7197ab..d41dc6654a4 100644
--- a/libgfortran/ChangeLog
+++ b/libgfortran/ChangeLog
@@ -1,3 +1,10 @@
+2008-01-24 Jerry DeLisle <jvdelisle@gcc.gnu.org>
+
+ PR libfortran/34876
+ * io/transfer.c (write_buf): Handle case of zero sized array.
+ (transfer_array): Set data pointer to NULL and size to zero. Then
+ make a data transfer and return.
+
2008-01-24 David Edelsohn <edelsohn@gnu.org>
* configure: Regenerate.
diff --git a/libgfortran/io/transfer.c b/libgfortran/io/transfer.c
index da3e3f2000c..e94eb7431e6 100644
--- a/libgfortran/io/transfer.c
+++ b/libgfortran/io/transfer.c
@@ -638,6 +638,14 @@ write_buf (st_parameter_dt *dtp, void *buf, size_t nbytes)
return FAILURE;
}
+ if (buf == NULL && nbytes == 0)
+ {
+ char *p;
+ p = write_block (dtp, dtp->u.p.current_unit->recl);
+ memset (p, 0, dtp->u.p.current_unit->recl);
+ return SUCCESS;
+ }
+
if (swrite (dtp->u.p.current_unit->s, buf, &nbytes) != 0)
{
generate_error (&dtp->common, LIBERROR_OS, NULL);
@@ -648,7 +656,6 @@ write_buf (st_parameter_dt *dtp, void *buf, size_t nbytes)
dtp->u.p.current_unit->bytes_left -= (gfc_offset) nbytes;
return SUCCESS;
-
}
/* Unformatted sequential. */
@@ -1507,9 +1514,15 @@ transfer_array (st_parameter_dt *dtp, gfc_array_char *desc, int kind,
extent[n] = desc->dim[n].ubound + 1 - desc->dim[n].lbound;
/* If the extent of even one dimension is zero, then the entire
- array section contains zero elements, so we return. */
+ array section contains zero elements, so we return after writing
+ a zero array record. */
if (extent[n] <= 0)
- return;
+ {
+ data = NULL;
+ tsize = 0;
+ dtp->u.p.transfer (dtp, iotype, data, kind, size, tsize);
+ return;
+ }
}
stride0 = stride[0];