From 3ae9eb270ae75ceb7aa29752ef3a85210b7ab52c Mon Sep 17 00:00:00 2001
From: "Steven G. Kargl" <kargls@comcast.net>
Date: Wed, 30 Mar 2005 00:30:51 +0000
Subject: [PATCH] gfortran.h (option_t): Change d8, i8, r8 to
 flag_default_double, flag_default_integer, flag_default_real

* gfortran.h (option_t): Change d8, i8, r8 to flag_default_double,
  flag_default_integer, flag_default_real
* invoke.texi: Update documentation
* lang.opt: Remove d8, i8, r8 definitions; Add fdefault-double-8
  fdefault-integer-8, and fdefault-real-8 definitions.
* options.c (gfc_init_options): Set option defaults
  (gfc_handle_option): Handle command line options.
* trans-types.c (gfc_init_kinds): Use options.

From-SVN: r97221
---
 gcc/fortran/ChangeLog     | 11 +++++++++++
 gcc/fortran/gfortran.h    |  7 ++++---
 gcc/fortran/invoke.texi   | 36 ++++++++++++++++++------------------
 gcc/fortran/lang.opt      | 22 +++++++++++-----------
 gcc/fortran/options.c     | 18 +++++++++---------
 gcc/fortran/trans-types.c | 21 ++++++++++++++-------
 6 files changed, 67 insertions(+), 48 deletions(-)

diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog
index ccbd3cb97c37..bdc5649096c6 100644
--- a/gcc/fortran/ChangeLog
+++ b/gcc/fortran/ChangeLog
@@ -1,3 +1,14 @@
+2005-03-29  Steven G. Kargl  <kargls@comcast.net>
+
+	* gfortran.h (option_t): Change d8, i8, r8 to flag_default_double,
+	flag_default_integer, flag_default_real
+	* invoke.texi: Update documentation
+	* lang.opt: Remove d8, i8, r8 definitions; Add fdefault-double-8   
+	fdefault-integer-8, and fdefault-real-8 definitions.
+	* options.c (gfc_init_options): Set option defaults
+	(gfc_handle_option): Handle command line options.
+	* trans-types.c (gfc_init_kinds): Use options.
+
 2005-03-29  Keith Besaw  <kbesaw@us.ibm.com>
 
 	* f95-lang.c (builtin_function): Process the attrs parameter
diff --git a/gcc/fortran/gfortran.h b/gcc/fortran/gfortran.h
index b2167727a759..60a3040b85f2 100644
--- a/gcc/fortran/gfortran.h
+++ b/gcc/fortran/gfortran.h
@@ -1402,6 +1402,9 @@ typedef struct
   int warn_surprising;
   int warn_unused_labels;
 
+  int flag_default_double;
+  int flag_default_integer;
+  int flag_default_real;
   int flag_dollar_ok;
   int flag_underscoring;
   int flag_second_underscore;
@@ -1413,9 +1416,7 @@ typedef struct
   int flag_repack_arrays;
 
   int q_kind;
-  int r8;
-  int i8;
-  int d8;
+
   int warn_std;
   int allow_std;
   int warn_nonstd_intrinsics;
diff --git a/gcc/fortran/invoke.texi b/gcc/fortran/invoke.texi
index 376e9cc3101e..e5b93902a38c 100644
--- a/gcc/fortran/invoke.texi
+++ b/gcc/fortran/invoke.texi
@@ -119,7 +119,7 @@ by type.  Explanations are in the following sections.
 -fdollar-ok  -fimplicit-none  -fmax-identifier-length @gol
 -std=@var{std}
 -ffixed-line-length-@var{n}  -ffixed-line-length-none @gol
--i8  -r8  -d8}
+-fdefault-double-8  -fdefault-integer-8  -fdefault-real-8 }
 
 @item Warning Options
 @xref{Warning Options,,Options to Request or Suppress Warnings}.
@@ -183,6 +183,23 @@ Specify the layout used by the the source file. The free form layout
 was introduced in Fortran 90.  Fixed form was traditionally used in
 older Fortran programs.
 
+@cindex option, -fdefault-double-8
+@cindex -fdefault-double-8, option
+@item -fdefault-double-8
+Set the "DOUBLE PRECISION" type to an 8 byte wide.
+
+@cindex option, -fdefault-integer-8
+@cindex -fdefault-integer-8, option
+@item -fdefault-integer-8
+Set the default integer and logical types to an 8 byte wide type.
+Do nothing if this is already the default.
+
+@cindex option, -fdefault-real-8
+@cindex -fdefault-real-8, option
+@item -fdefault-real-8
+Set the default real type to an 8 byte wide type.
+Do nothing if this is already the default.
+
 @cindex -fdollar-ok option
 @cindex options, -fdollar-ok
 @item -fdollar-ok
@@ -233,23 +250,6 @@ Specify that no implicit typing is allowed, unless overridden by explicit
 Conform to the specified standard.  Allowed values for @var{std} are
 @samp{gnu}, @samp{f95} and @samp{f90}.
 
-@cindex option, -i8
-@cindex -i8, option
-@cindex option, -r8
-@cindex -r8, option
-@cindex option, -d8
-@cindex -d8, option
-@item -i8
-@item -r8
-@item -d8
-The @option{-i8} and @option{-r8} options set the default @code{INTEGER}
-and @code{REAL} kinds to @code{KIND=8}.  The @option{-d8} option is
-equivalent to specifying both @option{-i8} and @option{-r8}.
-
-When @option{-r8} is specified, the @code{DOUBLE PRECISION} kind is set
-to @code{KIND=16} if the target supports a 16 byte floating point format.
-If no such format exists, the @code{DOUBLE PRECISION} kind is unchanged.
-
 @end table
 
 @node Warning Options
diff --git a/gcc/fortran/lang.opt b/gcc/fortran/lang.opt
index 976a2b436d24..bde1d753b073 100644
--- a/gcc/fortran/lang.opt
+++ b/gcc/fortran/lang.opt
@@ -69,9 +69,17 @@ Wunused-labels
 F95
 Warn when a label is unused
 
-d8
-F95 RejectNegative
-Set the default real and integer kinds to double precision
+fdefault-double-8
+F95
+Set the default double precision kind to an 8 byte wide type
+
+fdefault-integer-8
+F95
+Set the default integer kind to an 8 byte wide type
+
+fdefault-real-8
+F95
+Set the default real kind to an 8 byte wide type
 
 fdollar-ok
 F95
@@ -133,18 +141,10 @@ frepack-arrays
 F95
 Copy array sections into a contiguous block on procedure entry
 
-i8
-F95
-Set the default integer kind to double precision
-
 qkind=
 F95 RejectNegative Joined UInteger
 -qkind=<n>	Set the kind for a real with the 'q' exponent to 'n'
 
-r8
-F95
-Set the default real kind to double precision
-
 std=f95
 F95
 Conform to the ISO Fortran 95 standard.
diff --git a/gcc/fortran/options.c b/gcc/fortran/options.c
index 359640037859..21fb0a83c522 100644
--- a/gcc/fortran/options.c
+++ b/gcc/fortran/options.c
@@ -57,6 +57,9 @@ gfc_init_options (unsigned int argc ATTRIBUTE_UNUSED,
   gfc_option.warn_surprising = 0;
   gfc_option.warn_unused_labels = 0;
 
+  gfc_option.flag_default_double = 0;
+  gfc_option.flag_default_integer = 0;
+  gfc_option.flag_default_real = 0;
   gfc_option.flag_dollar_ok = 0;
   gfc_option.flag_underscoring = 1;
   gfc_option.flag_second_underscore = 1;
@@ -68,9 +71,6 @@ gfc_init_options (unsigned int argc ATTRIBUTE_UNUSED,
   gfc_option.flag_repack_arrays = 0;
 
   gfc_option.q_kind = gfc_default_double_kind;
-  gfc_option.i8 = 0;
-  gfc_option.r8 = 0;
-  gfc_option.d8 = 0;
 
   flag_argument_noalias = 2;
   flag_errno_math = 0;
@@ -285,16 +285,16 @@ gfc_handle_option (size_t scode, const char *arg, int value)
       gfc_option.q_kind = value;
       break;
 
-    case OPT_i8:
-      gfc_option.i8 = value;
+    case OPT_fdefault_integer_8:
+      gfc_option.flag_default_integer = value;
       break;
 
-    case OPT_r8:
-      gfc_option.r8 = value;
+    case OPT_fdefault_real_8:
+      gfc_option.flag_default_real = value;
       break;
 
-    case OPT_d8:
-      gfc_option.d8 = value;
+    case OPT_fdefault_double_8:
+      gfc_option.flag_default_double = value;
       break;
 
     case OPT_I:
diff --git a/gcc/fortran/trans-types.c b/gcc/fortran/trans-types.c
index b64f868dbadd..11f17ddee60b 100644
--- a/gcc/fortran/trans-types.c
+++ b/gcc/fortran/trans-types.c
@@ -187,10 +187,10 @@ gfc_init_kinds (void)
 
   /* Choose the default integer kind.  We choose 4 unless the user
      directs us otherwise.  */
-  if (gfc_option.i8)
+  if (gfc_option.flag_default_integer)
     {
       if (!saw_i8)
-	fatal_error ("integer kind=8 not available for -i8 option");
+	fatal_error ("integer kind=8 not available for -fdefault-integer-8 option");
       gfc_default_integer_kind = 8;
     }
   else if (saw_i4)
@@ -199,10 +199,10 @@ gfc_init_kinds (void)
     gfc_default_integer_kind = gfc_integer_kinds[i_index - 1].kind;
 
   /* Choose the default real kind.  Again, we choose 4 when possible.  */
-  if (gfc_option.r8)
+  if (gfc_option.flag_default_real)
     {
       if (!saw_r8)
-	fatal_error ("real kind=8 not available for -r8 option");
+	fatal_error ("real kind=8 not available for -fdefault-real-8 option");
       gfc_default_real_kind = 8;
     }
   else if (saw_r4)
@@ -210,9 +210,16 @@ gfc_init_kinds (void)
   else
     gfc_default_real_kind = gfc_real_kinds[0].kind;
 
-  /* Choose the default double kind.  If -r8 is specified, we use kind=16,
-     if it's available, otherwise we do not change anything.  */
-  if (gfc_option.r8 && saw_r16)
+  /* Choose the default double kind.  If -fdefault-real and -fdefault-double 
+     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 (gfc_option.flag_default_double && !gfc_option.flag_default_real)
+    fatal_error ("Use of -fdefault-double-8 requires -fdefault-real-8");
+
+  if (gfc_option.flag_default_real && gfc_option.flag_default_double && saw_r8)
+    gfc_default_double_kind = 8;
+  else if (gfc_option.flag_default_real && saw_r16)
     gfc_default_double_kind = 16;
   else if (saw_r4 && saw_r8)
     gfc_default_double_kind = 8;
-- 
GitLab