Commit 6b680210 by Janne Blomqvist

PR libfortran/39665 libfortran/39702 libfortran/39709

2009-04-10  Janne Blomqvist  <jb@gcc.gnu.org>

	PR libfortran/39665 libfortran/39702 libfortran/39709
	* io/io.h (st_parameter_dt): Revert aligned attribute from u.p.value.
        * io/list_read.c (read_complex): Read directly into user pointer.
        (read_real): Likewise.
        (list_formatted_read_scalar): Update read_complex and read_real calls.
        (nml_read_obj): Read directly into user pointer.

From-SVN: r145875
parent 8b7a6bb2
2009-04-10 Janne Blomqvist <jb@gcc.gnu.org>
PR libfortran/39665 libfortran/39702 libfortran/39709
* io/io.h (st_parameter_dt): Revert aligned attribute from u.p.value.
* io/list_read.c (read_complex): Read directly into user pointer.
(read_real): Likewise.
(list_formatted_read_scalar): Update read_complex and read_real calls.
(nml_read_obj): Read directly into user pointer.
2009-04-09 Janne Blomqvist <jb@gcc.gnu.org> 2009-04-09 Janne Blomqvist <jb@gcc.gnu.org>
PR libfortran/39665 PR libfortran/39665
......
...@@ -500,9 +500,8 @@ typedef struct st_parameter_dt ...@@ -500,9 +500,8 @@ typedef struct st_parameter_dt
int expanded_read; int expanded_read;
/* Storage area for values except for strings. Must be /* Storage area for values except for strings. Must be
large enough to hold a complex value (two reals) of the large enough to hold a complex value (two reals) of the
largest kind. It must also be sufficiently aligned for largest kind. */
assigning any type we use into it. */ char value[32];
char value[32] __attribute__ ((aligned (__BIGGEST_ALIGNMENT__)));
GFC_IO_INT size_used; GFC_IO_INT size_used;
} p; } p;
/* This pad size must be equal to the pad_size declared in /* This pad size must be equal to the pad_size declared in
......
...@@ -1219,7 +1219,7 @@ parse_real (st_parameter_dt *dtp, void *buffer, int length) ...@@ -1219,7 +1219,7 @@ parse_real (st_parameter_dt *dtp, void *buffer, int length)
what it is right away. */ what it is right away. */
static void static void
read_complex (st_parameter_dt *dtp, int kind, size_t size) read_complex (st_parameter_dt *dtp, void * dest, int kind, size_t size)
{ {
char message[100]; char message[100];
char c; char c;
...@@ -1243,7 +1243,7 @@ read_complex (st_parameter_dt *dtp, int kind, size_t size) ...@@ -1243,7 +1243,7 @@ read_complex (st_parameter_dt *dtp, int kind, size_t size)
} }
eat_spaces (dtp); eat_spaces (dtp);
if (parse_real (dtp, dtp->u.p.value, kind)) if (parse_real (dtp, dest, kind))
return; return;
eol_1: eol_1:
...@@ -1266,7 +1266,7 @@ eol_2: ...@@ -1266,7 +1266,7 @@ eol_2:
else else
unget_char (dtp, c); unget_char (dtp, c);
if (parse_real (dtp, dtp->u.p.value + size / 2, kind)) if (parse_real (dtp, dest + size / 2, kind))
return; return;
eat_spaces (dtp); eat_spaces (dtp);
...@@ -1300,7 +1300,7 @@ eol_2: ...@@ -1300,7 +1300,7 @@ eol_2:
/* Parse a real number with a possible repeat count. */ /* Parse a real number with a possible repeat count. */
static void static void
read_real (st_parameter_dt *dtp, int length) read_real (st_parameter_dt *dtp, void * dest, int length)
{ {
char c, message[100]; char c, message[100];
int seen_dp; int seen_dp;
...@@ -1513,7 +1513,7 @@ read_real (st_parameter_dt *dtp, int length) ...@@ -1513,7 +1513,7 @@ read_real (st_parameter_dt *dtp, int length)
unget_char (dtp, c); unget_char (dtp, c);
eat_separator (dtp); eat_separator (dtp);
push_char (dtp, '\0'); push_char (dtp, '\0');
if (convert_real (dtp, dtp->u.p.value, dtp->u.p.saved_string, length)) if (convert_real (dtp, dest, dtp->u.p.saved_string, length))
return; return;
free_saved (dtp); free_saved (dtp);
...@@ -1757,10 +1757,16 @@ list_formatted_read_scalar (st_parameter_dt *dtp, volatile bt type, void *p, ...@@ -1757,10 +1757,16 @@ list_formatted_read_scalar (st_parameter_dt *dtp, volatile bt type, void *p,
read_character (dtp, kind); read_character (dtp, kind);
break; break;
case BT_REAL: case BT_REAL:
read_real (dtp, kind); read_real (dtp, p, kind);
/* Copy value back to temporary if needed. */
if (dtp->u.p.repeat_count > 0)
memcpy (dtp->u.p.value, p, kind);
break; break;
case BT_COMPLEX: case BT_COMPLEX:
read_complex (dtp, kind, size); read_complex (dtp, p, kind, size);
/* Copy value back to temporary if needed. */
if (dtp->u.p.repeat_count > 0)
memcpy (dtp->u.p.value, p, size);
break; break;
default: default:
internal_error (&dtp->common, "Bad type for list read"); internal_error (&dtp->common, "Bad type for list read");
...@@ -1776,8 +1782,12 @@ list_formatted_read_scalar (st_parameter_dt *dtp, volatile bt type, void *p, ...@@ -1776,8 +1782,12 @@ list_formatted_read_scalar (st_parameter_dt *dtp, volatile bt type, void *p,
switch (dtp->u.p.saved_type) switch (dtp->u.p.saved_type)
{ {
case BT_COMPLEX: case BT_COMPLEX:
case BT_INTEGER:
case BT_REAL: case BT_REAL:
if (dtp->u.p.repeat_count > 0)
memcpy (p, dtp->u.p.value, size);
break;
case BT_INTEGER:
case BT_LOGICAL: case BT_LOGICAL:
memcpy (p, dtp->u.p.value, size); memcpy (p, dtp->u.p.value, size);
break; break;
...@@ -2379,12 +2389,17 @@ nml_read_obj (st_parameter_dt *dtp, namelist_info * nl, index_type offset, ...@@ -2379,12 +2389,17 @@ nml_read_obj (st_parameter_dt *dtp, namelist_info * nl, index_type offset,
break; break;
case GFC_DTYPE_REAL: case GFC_DTYPE_REAL:
read_real (dtp, len); /* Need to copy data back from the real location to the temp in order
break; to handle nml reads into arrays. */
read_real (dtp, pdata, len);
memcpy (dtp->u.p.value, pdata, dlen);
break;
case GFC_DTYPE_COMPLEX: case GFC_DTYPE_COMPLEX:
read_complex (dtp, len, dlen); /* Same as for REAL, copy back to temp. */
break; read_complex (dtp, pdata, len, dlen);
memcpy (dtp->u.p.value, pdata, dlen);
break;
case GFC_DTYPE_DERIVED: case GFC_DTYPE_DERIVED:
obj_name_len = strlen (nl->var_name) + 1; obj_name_len = strlen (nl->var_name) + 1;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment