summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjanus <janus@138bc75d-0d04-0410-961f-82ee72b054a4>2017-09-23 13:15:20 +0000
committerjanus <janus@138bc75d-0d04-0410-961f-82ee72b054a4>2017-09-23 13:15:20 +0000
commit51b237e3341f34f3a872ca47cdd9e8da066bd250 (patch)
treeccd358e62d41b796f12904b956dea9450ef1e93b
parent4d6bb87edda4cdb2fbc4f3e06bfe8d423115a950 (diff)
downloadgcc-51b237e3341f34f3a872ca47cdd9e8da066bd250.tar.gz
2017-09-23 Janus Weil <janus@gcc.gnu.org>
PR fortran/82143 * lang.opt: Add the options -fdefault-real-10 and -fdefault-real-16. Rename flag_default_real to flag_default_real_8. * invoke.texi: Add documentation. * module.c (use_iso_fortran_env_module): flag_default_real is renamed. * trans-types.c (gfc_init_kinds): Implement the flags -fdefault-real-10 and -fdefault-real-16. Make -fdefault-double-8 work without -fdefault-real-8. 2017-09-23 Janus Weil <janus@gcc.gnu.org> PR fortran/82143 * gfortran.dg/promotion_3.f90: New test case. * gfortran.dg/promotion_4.f90: New test case. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@253117 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--gcc/fortran/ChangeLog11
-rw-r--r--gcc/fortran/invoke.texi20
-rw-r--r--gcc/fortran/lang.opt10
-rw-r--r--gcc/fortran/module.c4
-rw-r--r--gcc/fortran/trans-types.c38
-rw-r--r--gcc/testsuite/ChangeLog6
-rw-r--r--gcc/testsuite/gfortran.dg/promotion_3.f9016
-rw-r--r--gcc/testsuite/gfortran.dg/promotion_4.f9016
8 files changed, 108 insertions, 13 deletions
diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog
index 32d3b217a98..c3c4f188737 100644
--- a/gcc/fortran/ChangeLog
+++ b/gcc/fortran/ChangeLog
@@ -1,3 +1,14 @@
+2017-09-23 Janus Weil <janus@gcc.gnu.org>
+
+ PR fortran/82143
+ * lang.opt: Add the options -fdefault-real-10 and -fdefault-real-16.
+ Rename flag_default_real to flag_default_real_8.
+ * invoke.texi: Add documentation.
+ * module.c (use_iso_fortran_env_module): flag_default_real is renamed.
+ * trans-types.c (gfc_init_kinds): Implement the flags
+ -fdefault-real-10 and -fdefault-real-16. Make -fdefault-double-8 work
+ without -fdefault-real-8.
+
2017-09-21 Paul Thomas <pault@gcc.gnu.org>
PR fortran/52832
diff --git a/gcc/fortran/invoke.texi b/gcc/fortran/invoke.texi
index a478aed922a..f3f931fd3da 100644
--- a/gcc/fortran/invoke.texi
+++ b/gcc/fortran/invoke.texi
@@ -119,8 +119,8 @@ by type. Explanations are in the following sections.
@gccoptlist{-fall-intrinsics -fbackslash -fcray-pointer -fd-lines-as-code @gol
-fd-lines-as-comments @gol
-fdec -fdec-structure -fdec-intrinsic-ints -fdec-static -fdec-math @gol
--fdefault-double-8 -fdefault-integer-8 @gol
--fdefault-real-8 -fdollar-ok -ffixed-line-length-@var{n} @gol
+-fdefault-double-8 -fdefault-integer-8 -fdefault-real-8 @gol
+-fdefault-real-10 -fdefault-real-16 -fdollar-ok -ffixed-line-length-@var{n} @gol
-ffixed-line-length-none -ffree-form -ffree-line-length-@var{n} @gol
-ffree-line-length-none -fimplicit-none -finteger-4-integer-8 @gol
-fmax-identifier-length -fmodule-private -ffixed-form -fno-range-check @gol
@@ -404,6 +404,22 @@ the default width of @code{DOUBLE PRECISION} to 16 bytes if possible, unless
@code{-fdefault-double-8} is given, too. Unlike @option{-freal-4-real-8},
it does not promote variables with explicit kind declaration.
+@item -fdefault-real-10
+@opindex @code{fdefault-real-10}
+Set the default real type to a 10 byte wide type. This option also affects
+the kind of non-double real constants like @code{1.0}, and does promote
+the default width of @code{DOUBLE PRECISION} to 16 bytes if possible, unless
+@code{-fdefault-double-8} is given. Unlike @option{-freal-4-real-10},
+it does not promote variables with explicit kind declaration.
+
+@item -fdefault-real-16
+@opindex @code{fdefault-real-16}
+Set the default real type to a 16 byte wide type. This option also affects
+the kind of non-double real constants like @code{1.0}, and does promote
+the default width of @code{DOUBLE PRECISION} to 16 bytes if possible, unless
+@code{-fdefault-double-8} is given. Unlike @option{-freal-4-real-16},
+it does not promote variables with explicit kind declaration.
+
@item -fdefault-double-8
@opindex @code{fdefault-double-8}
Set the @code{DOUBLE PRECISION} type to an 8 byte wide type. Do nothing if this
diff --git a/gcc/fortran/lang.opt b/gcc/fortran/lang.opt
index 94185da103e..34341e5b35b 100644
--- a/gcc/fortran/lang.opt
+++ b/gcc/fortran/lang.opt
@@ -457,9 +457,17 @@ Fortran Var(flag_default_integer)
Set the default integer kind to an 8 byte wide type.
fdefault-real-8
-Fortran Var(flag_default_real)
+Fortran Var(flag_default_real_8)
Set the default real kind to an 8 byte wide type.
+fdefault-real-10
+Fortran Var(flag_default_real_10)
+Set the default real kind to an 10 byte wide type.
+
+fdefault-real-16
+Fortran Var(flag_default_real_16)
+Set the default real kind to an 16 byte wide type.
+
fdollar-ok
Fortran Var(flag_dollar_ok)
Allow dollar signs in entity names.
diff --git a/gcc/fortran/module.c b/gcc/fortran/module.c
index d71221ca966..63877a08050 100644
--- a/gcc/fortran/module.c
+++ b/gcc/fortran/module.c
@@ -6741,7 +6741,7 @@ use_iso_fortran_env_module (void)
"standard", symbol[i].name, &u->where))
continue;
- if ((flag_default_integer || flag_default_real)
+ if ((flag_default_integer || flag_default_real_8)
&& symbol[i].id == ISOFORTRANENV_NUMERIC_STORAGE_SIZE)
gfc_warning_now (0, "Use of the NUMERIC_STORAGE_SIZE named "
"constant from intrinsic module "
@@ -6808,7 +6808,7 @@ use_iso_fortran_env_module (void)
if ((gfc_option.allow_std & symbol[i].standard) == 0)
continue;
- if ((flag_default_integer || flag_default_real)
+ if ((flag_default_integer || flag_default_real_8)
&& symbol[i].id == ISOFORTRANENV_NUMERIC_STORAGE_SIZE)
gfc_warning_now (0,
"Use of the NUMERIC_STORAGE_SIZE named constant "
diff --git a/gcc/fortran/trans-types.c b/gcc/fortran/trans-types.c
index b106794205b..78477a90f80 100644
--- a/gcc/fortran/trans-types.c
+++ b/gcc/fortran/trans-types.c
@@ -530,7 +530,7 @@ gfc_init_kinds (void)
}
/* Choose the default real kind. Again, we choose 4 when possible. */
- if (flag_default_real)
+ if (flag_default_real_8)
{
if (!saw_r8)
gfc_fatal_error ("REAL(KIND=8) is not available for "
@@ -538,6 +538,22 @@ gfc_init_kinds (void)
gfc_default_real_kind = 8;
}
+ else if (flag_default_real_10)
+ {
+ if (!saw_r10)
+ gfc_fatal_error ("REAL(KIND=10) is not available for "
+ "%<-fdefault-real-10%> option");
+
+ gfc_default_real_kind = 10;
+ }
+ else if (flag_default_real_16)
+ {
+ if (!saw_r16)
+ gfc_fatal_error ("REAL(KIND=16) is not available for "
+ "%<-fdefault-real-16%> option");
+
+ gfc_default_real_kind = 16;
+ }
else if (flag_real4_kind == 8)
{
if (!saw_r8)
@@ -571,14 +587,20 @@ gfc_init_kinds (void)
are specified, we use kind=8, if it's available. If -fdefault-real is
specified without -fdefault-double, we use kind=16, if it's available.
Otherwise we do not change anything. */
- if (flag_default_double && !flag_default_real)
- gfc_fatal_error ("Use of %<-fdefault-double-8%> requires "
- "%<-fdefault-real-8%>");
-
- if (flag_default_real && flag_default_double && saw_r8)
+ if (flag_default_double && saw_r8)
gfc_default_double_kind = 8;
- else if (flag_default_real && saw_r16)
- gfc_default_double_kind = 16;
+ else if (flag_default_real_8 || flag_default_real_10 || flag_default_real_16)
+ {
+ /* Use largest available kind. */
+ if (saw_r16)
+ gfc_default_double_kind = 16;
+ else if (saw_r10)
+ gfc_default_double_kind = 10;
+ else if (saw_r8)
+ gfc_default_double_kind = 8;
+ else
+ gfc_default_double_kind = gfc_default_real_kind;
+ }
else if (flag_real8_kind == 4)
{
if (!saw_r4)
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index b1a0471986c..c1a38f8add3 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,9 @@
+2017-09-23 Janus Weil <janus@gcc.gnu.org>
+
+ PR fortran/82143
+ * gfortran.dg/promotion_3.f90: New test case.
+ * gfortran.dg/promotion_4.f90: New test case.
+
2017-09-23 Daniel Santos <daniel.santos@pobox.com>
* gcc.target/i386/pr82196-1.c: (b): Remove volatile asm.
diff --git a/gcc/testsuite/gfortran.dg/promotion_3.f90 b/gcc/testsuite/gfortran.dg/promotion_3.f90
new file mode 100644
index 00000000000..7c9b5917fc8
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/promotion_3.f90
@@ -0,0 +1,16 @@
+! { 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
+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
diff --git a/gcc/testsuite/gfortran.dg/promotion_4.f90 b/gcc/testsuite/gfortran.dg/promotion_4.f90
new file mode 100644
index 00000000000..0aa1c8edbc4
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/promotion_4.f90
@@ -0,0 +1,16 @@
+! { dg-do run }
+! { dg-options "-fdefault-real-10" }
+!
+! 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
+if (kind(r4) /= 4) call abort
+if (kind(r8) /= 8) call abort
+if (kind(r) /= 10) call abort
+if (kind(d) /= 16) call abort
+end