summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortromey <tromey@138bc75d-0d04-0410-961f-82ee72b054a4>2000-11-06 05:35:53 +0000
committertromey <tromey@138bc75d-0d04-0410-961f-82ee72b054a4>2000-11-06 05:35:53 +0000
commitab3a735944aa71e2e91e5f9824346756576f6806 (patch)
treee88453b5e6bdbc6ca750c761f042b84588f3f601
parent73cea1d4bee2166cb2f06a52469951614f8e6461 (diff)
downloadgcc-ab3a735944aa71e2e91e5f9824346756576f6806.tar.gz
* lex.h (JAVA_FLOAT_RANGE_ERROR): Typo fix.
* lex.c (IS_ZERO): New define. (java_perform_atof): Error on floating point underflow. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@37269 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--gcc/java/ChangeLog6
-rw-r--r--gcc/java/lex.c34
-rw-r--r--gcc/java/lex.h2
3 files changed, 39 insertions, 3 deletions
diff --git a/gcc/java/ChangeLog b/gcc/java/ChangeLog
index 5b77604a661..46fe17d1df2 100644
--- a/gcc/java/ChangeLog
+++ b/gcc/java/ChangeLog
@@ -1,3 +1,9 @@
+2000-11-05 Tom Tromey <tromey@cygnus.com>
+
+ * lex.h (JAVA_FLOAT_RANGE_ERROR): Typo fix.
+ * lex.c (IS_ZERO): New define.
+ (java_perform_atof): Error on floating point underflow.
+
2000-11-04 Tom Tromey <tromey@cygnus.com>
* lex.c (java_parse_escape_sequence): Only read two octal
diff --git a/gcc/java/lex.c b/gcc/java/lex.c
index 14505708065..be1fcf8e76f 100644
--- a/gcc/java/lex.c
+++ b/gcc/java/lex.c
@@ -774,6 +774,12 @@ struct jpa_args
int number_beginning;
};
+#ifdef REAL_ARITHMETIC
+#define IS_ZERO(X) (ereal_cmp (X, dconst0) == 0)
+#else
+#define IS_ZERO(X) ((X) == 0)
+#endif
+
static void java_perform_atof PARAMS ((PTR));
static void
@@ -789,12 +795,36 @@ java_perform_atof (av)
SET_REAL_VALUE_ATOF (value,
REAL_VALUE_ATOF (a->literal_token, TYPE_MODE (type)));
- if (REAL_VALUE_ISINF (value)
- || REAL_VALUE_ISNAN (value))
+ if (REAL_VALUE_ISINF (value) || REAL_VALUE_ISNAN (value))
{
JAVA_FLOAT_RANGE_ERROR ((a->fflag ? "float" : "double"));
value = DCONST0;
}
+ else if (IS_ZERO (value))
+ {
+ /* We check to see if the value is really 0 or if we've found an
+ underflow. We do this in the most primitive imaginable way. */
+ int really_zero = 1;
+ char *p = a->literal_token;
+ if (*p == '-')
+ ++p;
+ while (*p && *p != 'e' && *p != 'E')
+ {
+ if (*p != '0' && *p != '.')
+ {
+ really_zero = 0;
+ break;
+ }
+ ++p;
+ }
+ if (! really_zero)
+ {
+ int i = ctxp->c_line->current;
+ ctxp->c_line->current = number_beginning;
+ java_lex_error ("Floating point literal underflow", 0);
+ ctxp->c_line->current = i;
+ }
+ }
SET_LVAL_NODE_TYPE (build_real (type, value), type);
}
diff --git a/gcc/java/lex.h b/gcc/java/lex.h
index b43061e45ee..baa08c99e64 100644
--- a/gcc/java/lex.h
+++ b/gcc/java/lex.h
@@ -234,7 +234,7 @@ extern void set_float_handler PARAMS ((jmp_buf));
char msg [1024]; \
int i = ctxp->c_line->current; \
ctxp->c_line->current = number_beginning; \
- sprintf (msg, "Floating pointer literal exceeds range of `%s'", (m)); \
+ sprintf (msg, "Floating point literal exceeds range of `%s'", (m)); \
java_lex_error (msg, 0); \
ctxp->c_line->current = i; \
}