diff options
author | pfg <pfg@FreeBSD.org> | 2013-05-12 15:29:35 +0000 |
---|---|---|
committer | pfg <pfg@FreeBSD.org> | 2013-05-12 15:29:35 +0000 |
commit | b0d72f0d7ad6703e4a6d78b99590ac1fbcb716fb (patch) | |
tree | 09efed35d1d90aebbe44c54da46d272ea7bdb62d /contrib/gcclibs | |
parent | 168bd583e81022553017d75b42291248fd1b0f3e (diff) | |
download | FreeBSD-src-b0d72f0d7ad6703e4a6d78b99590ac1fbcb716fb.zip FreeBSD-src-b0d72f0d7ad6703e4a6d78b99590ac1fbcb716fb.tar.gz |
Add support for "d" floating-point suffix, as defined by draft N1312
of TR 24732. Emit pedantic warning if the feature is being used.
Should solve GCC bug 39027.
Obtained from: OpenBSD
MFC after: 2 weeks
Diffstat (limited to 'contrib/gcclibs')
-rw-r--r-- | contrib/gcclibs/libcpp/expr.c | 19 | ||||
-rw-r--r-- | contrib/gcclibs/libcpp/include/cpplib.h | 1 |
2 files changed, 17 insertions, 3 deletions
diff --git a/contrib/gcclibs/libcpp/expr.c b/contrib/gcclibs/libcpp/expr.c index 574b85f..bf8baaf 100644 --- a/contrib/gcclibs/libcpp/expr.c +++ b/contrib/gcclibs/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, d = 0; + size_t f = 0, l = 0, i = 0, d = 0, d0 = 0; while (len--) switch (s[len]) @@ -101,7 +101,12 @@ interpret_float_suffix (const uchar *s, size_t len) return 0; } - if (f + l > 1 || i > 1) + if (d == 1 && !f && !l) { + d = 0; + d0 = 1; + } + + if (f + d0 + l > 1 || i > 1) return 0; /* Allow dd, df, dl suffixes for decimal float constants. */ @@ -110,7 +115,8 @@ interpret_float_suffix (const uchar *s, size_t len) return ((i ? CPP_N_IMAGINARY : 0) | (f ? CPP_N_SMALL : - l ? CPP_N_LARGE : CPP_N_MEDIUM) + d0 ? CPP_N_MEDIUM : + l ? CPP_N_LARGE : CPP_N_DEFAULT) | (d ? CPP_N_DFLOAT : 0)); } @@ -261,6 +267,13 @@ cpp_classify_number (cpp_reader *pfile, const cpp_token *token) "traditional C rejects the \"%.*s\" suffix", (int) (limit - str), str); + /* A suffix for double is a GCC extension via decimal float support. + If the suffix also specifies an imaginary value we'll catch that + later. */ + if ((result == CPP_N_MEDIUM) && CPP_PEDANTIC (pfile)) + cpp_error (pfile, CPP_DL_PEDWARN, + "suffix for double constant is a GCC extension"); + /* Radix must be 10 for decimal floats. */ if ((result & CPP_N_DFLOAT) && radix != 10) { diff --git a/contrib/gcclibs/libcpp/include/cpplib.h b/contrib/gcclibs/libcpp/include/cpplib.h index c6a5efc..851a2e3 100644 --- a/contrib/gcclibs/libcpp/include/cpplib.h +++ b/contrib/gcclibs/libcpp/include/cpplib.h @@ -749,6 +749,7 @@ struct cpp_num #define CPP_N_UNSIGNED 0x1000 /* Properties. */ #define CPP_N_IMAGINARY 0x2000 #define CPP_N_DFLOAT 0x4000 +#define CPP_N_DEFAULT 0x8000 /* Classify a CPP_NUMBER token. The return value is a combination of the flags from the above sets. */ |