[Midnightbsd-cvs] src [9427] trunk/contrib: Add support for "d" floating-point suffix, as defined by draft N1312
laffer1 at midnightbsd.org
laffer1 at midnightbsd.org
Sat Mar 4 18:23:39 EST 2017
Revision: 9427
http://svnweb.midnightbsd.org/src/?rev=9427
Author: laffer1
Date: 2017-03-04 18:23:39 -0500 (Sat, 04 Mar 2017)
Log Message:
-----------
Add support for "d" floating-point suffix, as defined by draft N1312
of TR 24732. Emit pedantic warning if the feature is being used.
Modified Paths:
--------------
trunk/contrib/gcc4/c-lex.c
trunk/contrib/gcclibs/libcpp/expr.c
trunk/contrib/gcclibs/libcpp/include/cpplib.h
Modified: trunk/contrib/gcc4/c-lex.c
===================================================================
--- trunk/contrib/gcc4/c-lex.c 2017-03-04 23:22:55 UTC (rev 9426)
+++ trunk/contrib/gcc4/c-lex.c 2017-03-04 23:23:39 UTC (rev 9427)
@@ -640,6 +640,13 @@
char *copy;
size_t copylen;
+ /* Default (no suffix) is double. */
+ if (flags & CPP_N_DEFAULT)
+ {
+ flags ^= CPP_N_DEFAULT;
+ flags |= CPP_N_MEDIUM;
+ }
+
/* Decode type based on width and properties. */
if (flags & CPP_N_DFLOAT)
if ((flags & CPP_N_WIDTH) == CPP_N_LARGE)
Modified: trunk/contrib/gcclibs/libcpp/expr.c
===================================================================
--- trunk/contrib/gcclibs/libcpp/expr.c 2017-03-04 23:22:55 UTC (rev 9426)
+++ trunk/contrib/gcclibs/libcpp/expr.c 2017-03-04 23:23:39 UTC (rev 9427)
@@ -82,7 +82,7 @@
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 @@
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 @@
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 @@
"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)
{
Modified: trunk/contrib/gcclibs/libcpp/include/cpplib.h
===================================================================
--- trunk/contrib/gcclibs/libcpp/include/cpplib.h 2017-03-04 23:22:55 UTC (rev 9426)
+++ trunk/contrib/gcclibs/libcpp/include/cpplib.h 2017-03-04 23:23:39 UTC (rev 9427)
@@ -749,6 +749,7 @@
#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. */
More information about the Midnightbsd-cvs
mailing list