Commit 25292a1b by Jerry DeLisle

re PR libfortran/24459 ([4.1 Only] gfortran namelist problem)

2006-05-20  Jerry DeLisle  <jvdelisle@gcc.gnu.org>

	PR libgfortran/24459
	* io/list_read.c (nml_parse_qualifier): Leave loop spec end value
	at default value unless -std=f95 or if an array section
	is specified in namelist input.  Warn if -pedantic.
	* io/io.h (st_parameter_dt): Add expanded_read flag.

From-SVN: r113924
parent 8bf65196
2006-05-20 Jerry DeLisle <jvdelisle@gcc.gnu.org>
PR libgfortran/24459
* io/list_read.c (nml_parse_qualifier): Leave loop spec end value
at default value unless -std=f95 or if an array section
is specified in namelist input. Warn if -pedantic.
* io/io.h (st_parameter_dt): Add expanded_read flag.
2006-05-19 Jerry DeLisle <jvdelisle@gcc.gnu.org> 2006-05-19 Jerry DeLisle <jvdelisle@gcc.gnu.org>
PR libgfortran/22423 PR libgfortran/22423
......
...@@ -432,7 +432,9 @@ typedef struct st_parameter_dt ...@@ -432,7 +432,9 @@ typedef struct st_parameter_dt
struct format_data *fmt; struct format_data *fmt;
jmp_buf *eof_jump; jmp_buf *eof_jump;
namelist_info *ionml; namelist_info *ionml;
/* A flag used to identify when a non-standard expanded namelist read
has occurred. */
int expanded_read;
/* Storage area for values except for strings. Must be large /* Storage area for values except for strings. Must be large
enough to hold a complex value (two reals) of the largest enough to hold a complex value (two reals) of the largest
kind. */ kind. */
......
...@@ -1660,8 +1660,12 @@ nml_parse_qualifier (st_parameter_dt *dtp, descriptor_dimension *ad, ...@@ -1660,8 +1660,12 @@ nml_parse_qualifier (st_parameter_dt *dtp, descriptor_dimension *ad,
int indx; int indx;
int neg; int neg;
int null_flag; int null_flag;
int is_array_section;
char c; char c;
is_array_section = 0;
dtp->u.p.expanded_read = 0;
/* The next character in the stream should be the '('. */ /* The next character in the stream should be the '('. */
c = next_char (dtp); c = next_char (dtp);
...@@ -1700,6 +1704,7 @@ nml_parse_qualifier (st_parameter_dt *dtp, descriptor_dimension *ad, ...@@ -1700,6 +1704,7 @@ nml_parse_qualifier (st_parameter_dt *dtp, descriptor_dimension *ad,
switch (c) switch (c)
{ {
case ':': case ':':
is_array_section = 1;
break; break;
case ',': case ')': case ',': case ')':
...@@ -1775,7 +1780,14 @@ nml_parse_qualifier (st_parameter_dt *dtp, descriptor_dimension *ad, ...@@ -1775,7 +1780,14 @@ nml_parse_qualifier (st_parameter_dt *dtp, descriptor_dimension *ad,
if (indx == 0) if (indx == 0)
{ {
memcpy (&ls[dim].start, dtp->u.p.value, sizeof(ssize_t)); memcpy (&ls[dim].start, dtp->u.p.value, sizeof(ssize_t));
ls[dim].end = ls[dim].start;
/* If -std=f95/2003 or an array section is specified,
do not allow excess data to be processed. */
if (is_array_section == 1
|| compile_options.allow_std < GFC_STD_GNU)
ls[dim].end = ls[dim].start;
else
dtp->u.p.expanded_read = 1;
} }
break; break;
} }
...@@ -2112,6 +2124,10 @@ nml_read_obj (st_parameter_dt *dtp, namelist_info * nl, index_type offset, ...@@ -2112,6 +2124,10 @@ nml_read_obj (st_parameter_dt *dtp, namelist_info * nl, index_type offset,
strcpy (obj_name, nl->var_name); strcpy (obj_name, nl->var_name);
strcat (obj_name, "%"); strcat (obj_name, "%");
/* If reading a derived type, disable the expanded read warning
since a single object can have multiple reads. */
dtp->u.p.expanded_read = 0;
/* Now loop over the components. Update the component pointer /* Now loop over the components. Update the component pointer
with the return value from nml_write_obj. This loop jumps with the return value from nml_write_obj. This loop jumps
past nested derived types by testing if the potential past nested derived types by testing if the potential
...@@ -2157,11 +2173,16 @@ nml_read_obj (st_parameter_dt *dtp, namelist_info * nl, index_type offset, ...@@ -2157,11 +2173,16 @@ nml_read_obj (st_parameter_dt *dtp, namelist_info * nl, index_type offset,
*pprev_nl = nl; *pprev_nl = nl;
if (dtp->u.p.nml_read_error) if (dtp->u.p.nml_read_error)
return SUCCESS; {
dtp->u.p.expanded_read = 0;
return SUCCESS;
}
if (dtp->u.p.saved_type == GFC_DTYPE_UNKNOWN) if (dtp->u.p.saved_type == GFC_DTYPE_UNKNOWN)
goto incr_idx; {
dtp->u.p.expanded_read = 0;
goto incr_idx;
}
/* Note the switch from GFC_DTYPE_type to BT_type at this point. /* Note the switch from GFC_DTYPE_type to BT_type at this point.
This comes about because the read functions return BT_types. */ This comes about because the read functions return BT_types. */
...@@ -2182,14 +2203,27 @@ nml_read_obj (st_parameter_dt *dtp, namelist_info * nl, index_type offset, ...@@ -2182,14 +2203,27 @@ nml_read_obj (st_parameter_dt *dtp, namelist_info * nl, index_type offset,
memcpy (pdata, dtp->u.p.saved_string, m); memcpy (pdata, dtp->u.p.saved_string, m);
if (m < dlen) if (m < dlen)
memset ((void*)( pdata + m ), ' ', dlen - m); memset ((void*)( pdata + m ), ' ', dlen - m);
break; break;
default: default:
break; break;
} }
/* Break out of loop if scalar. */ /* Warn if a non-standard expanded read occurs. A single read of a
single object is acceptable. If a second read occurs, issue a warning
and set the flag to zero to prevent further warnings. */
if (dtp->u.p.expanded_read == 2)
{
notify_std (GFC_STD_GNU, "Non-standard expanded namelist read.");
dtp->u.p.expanded_read = 0;
}
/* If the expanded read warning flag is set, increment it,
indicating that a single read has occured. */
if (dtp->u.p.expanded_read >= 1)
dtp->u.p.expanded_read++;
/* Break out of loop if scalar. */
if (!nl->var_rank) if (!nl->var_rank)
break; break;
...@@ -2500,6 +2534,7 @@ namelist_read (st_parameter_dt *dtp) ...@@ -2500,6 +2534,7 @@ namelist_read (st_parameter_dt *dtp)
dtp->u.p.namelist_mode = 1; dtp->u.p.namelist_mode = 1;
dtp->u.p.input_complete = 0; dtp->u.p.input_complete = 0;
dtp->u.p.expanded_read = 0;
dtp->u.p.eof_jump = &eof_jump; dtp->u.p.eof_jump = &eof_jump;
if (setjmp (eof_jump)) if (setjmp (eof_jump))
......
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