diff options
author | Fritz Reese <fritzoreese@gmail.com> | 2016-11-03 18:09:44 +0000 |
---|---|---|
committer | Fritz Reese <foreese@gcc.gnu.org> | 2016-11-03 18:09:44 +0000 |
commit | 6869e9c69f446161edba48722a75813934643382 (patch) | |
tree | 4b3e9356f44befe3d696e42639572508aa2db76c /libgfortran | |
parent | 1bac673faf4a0a0bd0a5606dad9d98b33d568510 (diff) | |
download | gcc-6869e9c69f446161edba48722a75813934643382.zip gcc-6869e9c69f446161edba48722a75813934643382.tar.gz gcc-6869e9c69f446161edba48722a75813934643382.tar.bz2 |
Default missing exponents to 0 with -fdec.
gcc/fortran/
* gfortran.texi: Document.
* gfortran.h (gfc_dt): New field default_exp.
* primary.c (match_real_constant): Default exponent with -fdec.
* io.c (match_io): Set dt.default_exp with -fdec.
* ioparm.def (IOPARM_dt_default_exp): New.
* trans-io.c (build_dt): Set IOPARM_dt_default_exp with -fdec.
libgfortran/io/
* io.h (IOPARM_DT_DEFAULT_EXP): New flag bit.
* list_read.c (parse_real, read_real): Allow omission of exponent with
IOPARM_DT_DEFAULT_EXP.
* read.c (read_f): Ditto.
gcc/testsuite/gfortran.dg/
* dec_exp_1.f90, dec_exp_2.f90, dec_exp_3.f90: New testcases.
From-SVN: r241828
Diffstat (limited to 'libgfortran')
-rw-r--r-- | libgfortran/ChangeLog | 7 | ||||
-rw-r--r-- | libgfortran/io/io.h | 1 | ||||
-rw-r--r-- | libgfortran/io/list_read.c | 22 | ||||
-rw-r--r-- | libgfortran/io/read.c | 8 |
4 files changed, 35 insertions, 3 deletions
diff --git a/libgfortran/ChangeLog b/libgfortran/ChangeLog index 745adf7..d50ef47 100644 --- a/libgfortran/ChangeLog +++ b/libgfortran/ChangeLog @@ -1,3 +1,10 @@ +2016-11-03 Fritz Reese <fritzoreese@gmail.com> + + * io/io.h (IOPARM_DT_DEFAULT_EXP): New flag bit. + * io/list_read.c (parse_real, read_real): Allow omission of exponent + with IOPARM_DT_DEFAULT_EXP. + * io/read.c (read_f): Ditto. + 2016-10-31 Jerry DeLisle <jvdelisle@gcc.gnu.org> PR libgfortran/54679 diff --git a/libgfortran/io/io.h b/libgfortran/io/io.h index 7a54849..cd0a26f 100644 --- a/libgfortran/io/io.h +++ b/libgfortran/io/io.h @@ -443,6 +443,7 @@ st_parameter_inquire; #define IOPARM_DT_HAS_SIGN (1 << 24) #define IOPARM_DT_HAS_F2003 (1 << 25) #define IOPARM_DT_HAS_UDTIO (1 << 26) +#define IOPARM_DT_DEFAULT_EXP (1 << 27) /* Internal use bit. */ #define IOPARM_DT_IONML_SET (1u << 31) diff --git a/libgfortran/io/list_read.c b/libgfortran/io/list_read.c index f258c9d..a35beb8 100644 --- a/libgfortran/io/list_read.c +++ b/libgfortran/io/list_read.c @@ -1374,7 +1374,16 @@ parse_real (st_parameter_dt *dtp, void *buffer, int length) exp2: if (!isdigit (c)) - goto bad_exponent; + { + /* Extension: allow default exponent of 0 when omitted. */ + if (dtp->common.flags & IOPARM_DT_DEFAULT_EXP) + { + push_char (dtp, '0'); + goto done; + } + else + goto bad_exponent; + } push_char (dtp, c); @@ -1816,7 +1825,16 @@ read_real (st_parameter_dt *dtp, void * dest, int length) exp2: if (!isdigit (c)) - goto bad_exponent; + { + /* Extension: allow default exponent of 0 when omitted. */ + if (dtp->common.flags & IOPARM_DT_DEFAULT_EXP) + { + push_char (dtp, '0'); + goto done; + } + else + goto bad_exponent; + } push_char (dtp, c); diff --git a/libgfortran/io/read.c b/libgfortran/io/read.c index 23b6f64..508b3a0 100644 --- a/libgfortran/io/read.c +++ b/libgfortran/io/read.c @@ -1087,7 +1087,13 @@ exponent: the d parameter before explict conversion takes place. */ if (w == 0) - goto bad_float; + { + /* Extension: allow default exponent of 0 when omitted. */ + if (dtp->common.flags & IOPARM_DT_DEFAULT_EXP) + goto done; + else + goto bad_float; + } if (dtp->u.p.blank_status == BLANK_UNSPECIFIED) { |