summaryrefslogtreecommitdiffstats
path: root/gnu/gcc/libcpp/expr.c
diff options
context:
space:
mode:
authormartynas <martynas@openbsd.org>2013-04-04 22:01:32 +0000
committermartynas <martynas@openbsd.org>2013-04-04 22:01:32 +0000
commit341535f4ee001bb1fce8215b46eb7a89e1d0892b (patch)
tree26e8d4495038d63655211cf67b6ddde65d17b09c /gnu/gcc/libcpp/expr.c
parentThe intel_dp_i2c_aux_ch() function has to return Linux-style negative errno (diff)
downloadwireguard-openbsd-341535f4ee001bb1fce8215b46eb7a89e1d0892b.tar.xz
wireguard-openbsd-341535f4ee001bb1fce8215b46eb7a89e1d0892b.zip
Add support for "d" floating-point suffix, as defined by draft N1312
of TR 24732. Emit pedantic warning if the feature is being used. Requested by jasper@; needed by certain ports. OK miod@.
Diffstat (limited to 'gnu/gcc/libcpp/expr.c')
-rw-r--r--gnu/gcc/libcpp/expr.c19
1 files changed, 16 insertions, 3 deletions
diff --git a/gnu/gcc/libcpp/expr.c b/gnu/gcc/libcpp/expr.c
index 574b85ff656..bf8baaff265 100644
--- a/gnu/gcc/libcpp/expr.c
+++ b/gnu/gcc/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)
{