[gfortran] PATCH Fix PR 20058
Steve Kargl
sgk@troutmask.apl.washington.edu
Sat Feb 26 16:13:00 GMT 2005
On Mon, Feb 21, 2005 at 10:21:39AM -0800, Steve Kargl wrote:
> See the comment int primary.c for an explanation of what the
> patch does.
>
> 2005-02-21 Steven G. Kargl <kargls@comcast.net>
>
> * trans-type.c (gfc_max_integer_kind): New variable.
> (gfc_init_kinds): Initialize it.
> * gfortran.h (gfc_max_integer_kind): extern declaration
> * primary.c (match_boz_constant): Use it.
>
> * testsuite/gfortran.dg/boz_1.f90: Test BOZ constant
> * testsuite/gfortran.dg/boz_3.f90: Test conversion between kinds
> * testsuite/gfortran.dg/boz_4.f90: Test overflow errors
Here is an updated patch that includes Tobi suggestion of
initializing gfc_max_integer_kind at the end of the loop
in gfc_init_kinds. The patch also removes the gfortran
extension that permitted a kind suffix on a BOZ literal
constant.
Bootstrap and regtested on i386-*-freebsd6.0
The testsuite program are unchanged and located here:
http://gcc.gnu.org/ml/gcc-patches/2005-02/msg01253.html
Ok for mainline?
2005-02-26 Steven G. Kargl <kargls@comcast.net>
* trans-types.c (gfc_max_integer_kind): Declare
(gfc_init_kinds): Initialize it.
* gfortran.h (gfc_max_integer_kind): extern it.
* primary.c (match_boz_constant): Use it; remove gfortran extension
of kind suffixes on BOZ literal constants
--
Steve
-------------- next part --------------
Index: gfortran.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/fortran/gfortran.h,v
retrieving revision 1.58
diff -u -b -r1.58 gfortran.h
--- gfortran.h 24 Feb 2005 18:26:26 -0000 1.58
+++ gfortran.h 26 Feb 2005 15:49:49 -0000
@@ -1556,6 +1556,7 @@
int gfc_validate_kind (bt, int, bool);
extern int gfc_index_integer_kind;
extern int gfc_default_integer_kind;
+extern int gfc_max_integer_kind;
extern int gfc_default_real_kind;
extern int gfc_default_double_kind;
extern int gfc_default_character_kind;
Index: primary.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/fortran/primary.c,v
retrieving revision 1.22
diff -u -b -r1.22 primary.c
--- primary.c 24 Feb 2005 18:26:26 -0000 1.22
+++ primary.c 26 Feb 2005 15:49:51 -0000
@@ -300,17 +300,15 @@
match_digits (0, radix, buffer);
gfc_next_char (); /* Eat delimiter. */
- kind = get_kind ();
- if (kind == -1)
- return MATCH_ERROR;
- if (kind == -2)
- kind = gfc_default_integer_kind;
- else if (pedantic
- && (gfc_notify_std (GFC_STD_GNU, "Extension: Kind parameter "
- "suffix to boz literal constant at %C.")
- == FAILURE))
- return MATCH_ERROR;
+ /* In section 5.2.5 and following C567 in the Fortran 2003 standard, we find
+ "If a data-stmt-constant is a boz-literal-constant, the corresponding
+ variable shall be of type integer. The boz-literal-constant is treated
+ as if it were an int-literal-constant with a kind-param that specifies
+ the representation method with the largest decimal exponent range
+ supported by the processor." */
+
+ kind = gfc_max_integer_kind;
e = gfc_convert_integer (buffer, kind, radix, &gfc_current_locus);
if (gfc_range_check (e) != ARITH_OK)
Index: trans-types.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/fortran/trans-types.c,v
retrieving revision 1.37
diff -u -b -r1.37 trans-types.c
--- trans-types.c 23 Jan 2005 14:36:26 -0000 1.37
+++ trans-types.c 26 Feb 2005 15:49:59 -0000
@@ -81,6 +81,7 @@
/* The default kinds of the various types. */
int gfc_default_integer_kind;
+int gfc_max_integer_kind;
int gfc_default_real_kind;
int gfc_default_double_kind;
int gfc_default_character_kind;
@@ -135,6 +136,9 @@
i_index += 1;
}
+ /* Set the maximum integer kind. Used with at least BOZ constants. */
+ gfc_max_integer_kind = gfc_integer_kinds[i_index - 1].kind;
+
for (r_index = 0, mode = MIN_MODE_FLOAT; mode <= MAX_MODE_FLOAT; mode++)
{
const struct real_format *fmt = REAL_MODE_FORMAT (mode);
More information about the Fortran
mailing list