summaryrefslogtreecommitdiff
path: root/libcpp/expr.c
diff options
context:
space:
mode:
authorjsm28 <jsm28@138bc75d-0d04-0410-961f-82ee72b054a4>2010-01-01 18:08:17 +0000
committerjsm28 <jsm28@138bc75d-0d04-0410-961f-82ee72b054a4>2010-01-01 18:08:17 +0000
commit0074cd57671ee45db5fdf292561bcf04c57ed8bd (patch)
tree4377e3cf62ac8d551491136201deeb693025608f /libcpp/expr.c
parentf54ef8b6bdcb2db0a3bc5c76b028df7a75fe524d (diff)
libcpp:
PR preprocessor/41947 * expr.c (cpp_classify_number): Give error for hexadecimal floating-point constant with no digits before or after point. gcc/testsuite: * gcc.dg/c99-hexfloat-3.c: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@155558 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libcpp/expr.c')
-rw-r--r--libcpp/expr.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/libcpp/expr.c b/libcpp/expr.c
index 96dd2fde24ca..60cb2816a7ab 100644
--- a/libcpp/expr.c
+++ b/libcpp/expr.c
@@ -1,6 +1,6 @@
/* Parse C expressions for cpplib.
Copyright (C) 1987, 1992, 1994, 1995, 1997, 1998, 1999, 2000, 2001,
- 2002, 2004, 2008, 2009 Free Software Foundation.
+ 2002, 2004, 2008, 2009, 2010 Free Software Foundation.
Contributed by Per Bothner, 1994.
This program is free software; you can redistribute it and/or modify it
@@ -229,6 +229,7 @@ cpp_classify_number (cpp_reader *pfile, const cpp_token *token)
const uchar *limit;
unsigned int max_digit, result, radix;
enum {NOT_FLOAT = 0, AFTER_POINT, AFTER_EXPON} float_flag;
+ bool seen_digit;
/* If the lexer has done its job, length one can only be a single
digit. Fast-path this very common case. */
@@ -239,6 +240,7 @@ cpp_classify_number (cpp_reader *pfile, const cpp_token *token)
float_flag = NOT_FLOAT;
max_digit = 0;
radix = 10;
+ seen_digit = false;
/* First, interpret the radix. */
if (*str == '0')
@@ -267,6 +269,7 @@ cpp_classify_number (cpp_reader *pfile, const cpp_token *token)
if (ISDIGIT (c) || (ISXDIGIT (c) && radix == 16))
{
+ seen_digit = true;
c = hex_value (c);
if (c > max_digit)
max_digit = c;
@@ -332,6 +335,9 @@ cpp_classify_number (cpp_reader *pfile, const cpp_token *token)
return CPP_N_INVALID;
}
+ if (radix == 16 && !seen_digit)
+ SYNTAX_ERROR ("no digits in hexadecimal floating constant");
+
if (radix == 16 && CPP_PEDANTIC (pfile) && !CPP_OPTION (pfile, c99))
cpp_error (pfile, CPP_DL_PEDWARN,
"use of C99 hexadecimal floating constant");