diff options
author | Jon Grimm <jgrimm2@us.ibm.com> | 2005-12-06 23:13:15 +0000 |
---|---|---|
committer | Ben Elliston <bje@gcc.gnu.org> | 2005-12-07 10:13:15 +1100 |
commit | ad6ed77efd770405e0c861a7819ba4e3f9a9f756 (patch) | |
tree | 26d2e8e0bea6ee9e502a1040ff11525cbbc867b7 /libcpp | |
parent | 2b948876d87065efd5c0aeabe828a586b9454cbd (diff) | |
download | gcc-ad6ed77efd770405e0c861a7819ba4e3f9a9f756.zip gcc-ad6ed77efd770405e0c861a7819ba4e3f9a9f756.tar.gz gcc-ad6ed77efd770405e0c861a7819ba4e3f9a9f756.tar.bz2 |
cpplib.h (CPP_N_DFLOAT): New.
* include/cpplib.h (CPP_N_DFLOAT): New.
* expr.c (interpret_float_suffix): Identify df, dd, and dl
suffixes as decimal floating point constants.
(cpp_classify_number): Disallow hexadecimal DFP constants.
Co-Authored-By: Ben Elliston <bje@au.ibm.com>
From-SVN: r108133
Diffstat (limited to 'libcpp')
-rw-r--r-- | libcpp/ChangeLog | 8 | ||||
-rw-r--r-- | libcpp/expr.c | 24 | ||||
-rw-r--r-- | libcpp/include/cpplib.h | 1 |
3 files changed, 31 insertions, 2 deletions
diff --git a/libcpp/ChangeLog b/libcpp/ChangeLog index 312cb98..d96b55f 100644 --- a/libcpp/ChangeLog +++ b/libcpp/ChangeLog @@ -1,3 +1,11 @@ +2005-12-07 Jon Grimm <jgrimm2@us.ibm.com> + Ben Elliston <bje@au.ibm.com> + + * include/cpplib.h (CPP_N_DFLOAT): New. + * expr.c (interpret_float_suffix): Identify df, dd, and dl + suffixes as decimal floating point constants. + (cpp_classify_number): Disallow hexadecimal DFP constants. + 2005-11-14 Gerald Pfeifer <gerald@pfeifer.com> Ian Lance Taylor <ian@airs.com> diff --git a/libcpp/expr.c b/libcpp/expr.c index 32b1723..a61ff66 100644 --- a/libcpp/expr.c +++ b/libcpp/expr.c @@ -82,7 +82,7 @@ static void check_promotion (cpp_reader *, const struct op *); static unsigned int interpret_float_suffix (const uchar *s, size_t len) { - size_t f = 0, l = 0, i = 0; + size_t f = 0, l = 0, i = 0, d = 0; while (len--) switch (s[len]) @@ -91,6 +91,12 @@ interpret_float_suffix (const uchar *s, size_t len) case 'l': case 'L': l++; break; case 'i': case 'I': case 'j': case 'J': i++; break; + case 'd': case 'D': + /* Disallow fd, ld suffixes. */ + if (d && (f || l)) + return 0; + d++; + break; default: return 0; } @@ -98,9 +104,14 @@ interpret_float_suffix (const uchar *s, size_t len) if (f + l > 1 || i > 1) return 0; + /* Allow dd, df, dl suffixes for decimal float constants. */ + if (d && ((d + f + l != 2) || i)) + return 0; + return ((i ? CPP_N_IMAGINARY : 0) | (f ? CPP_N_SMALL : - l ? CPP_N_LARGE : CPP_N_MEDIUM)); + l ? CPP_N_LARGE : CPP_N_MEDIUM) + | (d ? CPP_N_DFLOAT : 0)); } /* Subroutine of cpp_classify_number. S points to an integer suffix @@ -250,6 +261,15 @@ cpp_classify_number (cpp_reader *pfile, const cpp_token *token) "traditional C rejects the \"%.*s\" suffix", (int) (limit - str), str); + /* Radix must be 10 for decimal floats. */ + if ((result & CPP_N_DFLOAT) && radix != 10) + { + cpp_error (pfile, CPP_DL_ERROR, + "invalid suffix \"%.*s\" with hexadecimal floating constant", + (int) (limit - str), str); + return CPP_N_INVALID; + } + result |= CPP_N_FLOATING; } else diff --git a/libcpp/include/cpplib.h b/libcpp/include/cpplib.h index 9ec022f..b5bece5 100644 --- a/libcpp/include/cpplib.h +++ b/libcpp/include/cpplib.h @@ -743,6 +743,7 @@ struct cpp_num #define CPP_N_UNSIGNED 0x1000 /* Properties. */ #define CPP_N_IMAGINARY 0x2000 +#define CPP_N_DFLOAT 0x4000 /* Classify a CPP_NUMBER token. The return value is a combination of the flags from the above sets. */ |