aboutsummaryrefslogtreecommitdiff
path: root/gcc/fortran/module.c
diff options
context:
space:
mode:
authorJanne Blomqvist <jb@gcc.gnu.org>2017-01-03 20:01:30 +0200
committerJanne Blomqvist <jb@gcc.gnu.org>2017-01-03 20:01:30 +0200
commit84aff3c2d4b487fe93f5caa6351c47d56145a6a1 (patch)
tree09d627d26346335c50d501ba2f2e2f39094071bc /gcc/fortran/module.c
parent47f2abdd0d8bc3a760041149a93e35bc5db9d54e (diff)
downloadgcc-84aff3c2d4b487fe93f5caa6351c47d56145a6a1.zip
gcc-84aff3c2d4b487fe93f5caa6351c47d56145a6a1.tar.gz
gcc-84aff3c2d4b487fe93f5caa6351c47d56145a6a1.tar.bz2
PR 78534 Revert r244011
r244011 caused regressions on 32-bit hosts. From-SVN: r244027
Diffstat (limited to 'gcc/fortran/module.c')
-rw-r--r--gcc/fortran/module.c43
1 files changed, 14 insertions, 29 deletions
diff --git a/gcc/fortran/module.c b/gcc/fortran/module.c
index d9c995f..d738cf4 100644
--- a/gcc/fortran/module.c
+++ b/gcc/fortran/module.c
@@ -1141,7 +1141,7 @@ static atom_type last_atom;
#define MAX_ATOM_SIZE 100
-static HOST_WIDE_INT atom_int;
+static int atom_int;
static char *atom_string, atom_name[MAX_ATOM_SIZE];
@@ -1271,7 +1271,7 @@ parse_string (void)
}
-/* Parse an integer. Should fit in a HOST_WIDE_INT. */
+/* Parse a small integer. */
static void
parse_integer (int c)
@@ -1288,6 +1288,8 @@ parse_integer (int c)
}
atom_int = 10 * atom_int + c - '0';
+ if (atom_int > 99999999)
+ bad_module ("Integer overflow");
}
}
@@ -1629,12 +1631,11 @@ write_char (char out)
static void
write_atom (atom_type atom, const void *v)
{
- char buffer[32];
+ char buffer[20];
/* Workaround -Wmaybe-uninitialized false positive during
profiledbootstrap by initializing them. */
- int len;
- HOST_WIDE_INT i = 0;
+ int i = 0, len;
const char *p;
switch (atom)
@@ -1653,9 +1654,11 @@ write_atom (atom_type atom, const void *v)
break;
case ATOM_INTEGER:
- i = *((const HOST_WIDE_INT *) v);
+ i = *((const int *) v);
+ if (i < 0)
+ gfc_internal_error ("write_atom(): Writing negative integer");
- snprintf (buffer, sizeof (buffer), HOST_WIDE_INT_PRINT_DEC, i);
+ sprintf (buffer, "%d", i);
p = buffer;
break;
@@ -1763,10 +1766,7 @@ static void
mio_integer (int *ip)
{
if (iomode == IO_OUTPUT)
- {
- HOST_WIDE_INT hwi = *ip;
- write_atom (ATOM_INTEGER, &hwi);
- }
+ write_atom (ATOM_INTEGER, ip);
else
{
require_atom (ATOM_INTEGER);
@@ -1774,18 +1774,6 @@ mio_integer (int *ip)
}
}
-static void
-mio_hwi (HOST_WIDE_INT *hwi)
-{
- if (iomode == IO_OUTPUT)
- write_atom (ATOM_INTEGER, hwi);
- else
- {
- require_atom (ATOM_INTEGER);
- *hwi = atom_int;
- }
-}
-
/* Read or write a gfc_intrinsic_op value. */
@@ -1795,7 +1783,7 @@ mio_intrinsic_op (gfc_intrinsic_op* op)
/* FIXME: Would be nicer to do this via the operators symbolic name. */
if (iomode == IO_OUTPUT)
{
- HOST_WIDE_INT converted = (HOST_WIDE_INT) *op;
+ int converted = (int) *op;
write_atom (ATOM_INTEGER, &converted);
}
else
@@ -2692,7 +2680,7 @@ mio_array_ref (gfc_array_ref *ar)
{
for (i = 0; i < ar->dimen; i++)
{
- HOST_WIDE_INT tmp = (HOST_WIDE_INT)ar->dimen_type[i];
+ int tmp = (int)ar->dimen_type[i];
write_atom (ATOM_INTEGER, &tmp);
}
}
@@ -3394,7 +3382,6 @@ fix_mio_expr (gfc_expr *e)
static void
mio_expr (gfc_expr **ep)
{
- HOST_WIDE_INT hwi;
gfc_expr *e;
atom_type t;
int flag;
@@ -3609,9 +3596,7 @@ mio_expr (gfc_expr **ep)
break;
case BT_CHARACTER:
- hwi = e->value.character.length;
- mio_hwi (&hwi);
- e->value.character.length = hwi;
+ mio_integer (&e->value.character.length);
e->value.character.string
= CONST_CAST (gfc_char_t *,
mio_allocated_wide_string (e->value.character.string,