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]

[Patch, Fortran] PR 82143: add a -fdefault-real-16 flag


Hi all,

attached is a (technically) simple patch that implements the compiler
flag "-fdefault-real-16" for gfortran.

I know that there is some opposition against this, but I am proposing
it anyway, because I do think it is useful after all. My reasoning is
as follows:

1) Despite tons of -freal-X-real-Y flags, there currently is no way to
only promote the default real kind to real(16).
2) Since a variable of default REAL kind does not specify a KIND value
explicitly, it is quite natural for a compiler to control this by
means of flags.
3) gfortran already has -fdefault-real-8 (which is used in lots of
real-world codes AFAIK) and does support quad-precision variables.
4) Other compilers do have flags for this as well (e.g. ifort's
"-real-size 128" etc).
5) I know that it is possible, any maybe cleaner, to declare variables
with explicit kinds instead of relying on compiler flags, but for
large and historically grown codes it is not always straightforward to
do this right away.
6) The patch does not modify the default behavior of gfortran.
7) No one who dislikes such compiler flags is forced to use them.
8) I don't see how this flag can cause any harm. It adds additional
possibilities of using the compiler and thus makes gfortran more
powerful (and more compatible with other compilers).

The patch regtests cleanly on x86_64-linux-gnu. Ok for trunk?

Cheers,
Janus


2017-09-17  Janus Weil  <janus@gcc.gnu.org>

    PR fortran/82143
    * lang.opt: Add the option -fdefault-real-16.
    * invoke.texi: Add documentation for -fdefault-real-16.
    * trans-types.c (gfc_init_kinds): Implement -fdefault-real-16.

2017-09-17  Janus Weil  <janus@gcc.gnu.org>

    PR fortran/82143
    * gfortran.dg/promotion_3.f90: New test case.

Attachment: pr82143.diff
Description: Text document

! { dg-do run }
! { dg-options "-fdefault-real-16" }
!
! PR 82143: add a -fdefault-real-16 flag
!
! Contributed by Janus Weil <janus@gcc.gnu.org>

real :: r
real(kind=4) :: r4
real(kind=8) :: r8
double precision :: d
print *, kind(r4), kind(r8), kind(r), kind(d)
if (kind(r4) /= 4) call abort
if (kind(r8) /= 8) call abort
if (kind(r) /= 16) call abort
if (kind(d) /= 16) call abort
end

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]