This is the mail archive of the fortran@gcc.gnu.org mailing list for the GNU Fortran project.
| Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
|---|---|---|
| Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
| Other format: | [Raw text] | |
All,
Attached is a patch to the GNU Fortran front-end and runtime library
(libgfortran) which accepts real numbers with missing exponents as if
'0' was given as the exponent when the compile flag -fdec is given,
for further compatibility with legacy compilers. By default, GNU
Fortran will reject real constants such as '9e' or '15.2e'. With the
patch and -fdec, such numbers are accepted and treated as '9e0' (9) or
'15.2e0' (15.2), both at compile-time through the front-end and at
runtime through libgfortran.
For compile-time this is trivial. For runtime, An IOPARM_DT flag bit
is added to the usual flags to track whether a program was compiled
with the "default exponent" behavior, which the library can detect at
runtime for programs individually. No space is required in the
st_parameter_dt structure, and the behavior should be
backwards-compatible (by design of the IOPARM structures/flags).
Bootstraps and regtests on x86_64-redhat-linux. OK for trunk?
---
Fritz Reese
From: Fritz Reese <fritzoreese@gmail.com>
Date: Wed, 5 Oct 2016 18:27:56 -0400
Subject: [PATCH] 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.
---
gcc/fortran/gfortran.h | 1 +
gcc/fortran/gfortran.texi | 10 ++++++++
gcc/fortran/io.c | 4 +++
gcc/fortran/ioparm.def | 1 +
gcc/fortran/primary.c | 19 ++++++++++++----
gcc/fortran/trans-io.c | 3 ++
gcc/testsuite/gfortran.dg/dec_exp_1.f90 | 35 +++++++++++++++++++++++++++++++
gcc/testsuite/gfortran.dg/dec_exp_2.f90 | 13 +++++++++++
gcc/testsuite/gfortran.dg/dec_exp_3.f90 | 15 +++++++++++++
libgfortran/io/io.h | 1 +
libgfortran/io/list_read.c | 22 +++++++++++++++++-
libgfortran/io/read.c | 8 ++++++-
12 files changed, 124 insertions(+), 8 deletions(-)
create mode 100644 gcc/testsuite/gfortran.dg/dec_exp_1.f90
create mode 100644 gcc/testsuite/gfortran.dg/dec_exp_2.f90
create mode 100644 gcc/testsuite/gfortran.dg/dec_exp_3.f90
Attachment:
dec_default_exp.diff
Description: Text document
| Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
|---|---|---|
| Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |