* expr.c (interpret_float_suffix): Identify df, dd, and dl
suffixes as decimal floating point constants.
(cpp_classify_number): Disallow hexadecimal DFP constants.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@108133
138bc75d-0d04-0410-961f-
82ee72b054a4
+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>
2005-11-14 Gerald Pfeifer <gerald@pfeifer.com>
Ian Lance Taylor <ian@airs.com>
static unsigned int
interpret_float_suffix (const uchar *s, size_t len)
{
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])
while (len--)
switch (s[len])
case 'l': case 'L': l++; break;
case 'i': case 'I':
case 'j': case 'J': i++; break;
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;
if (f + l > 1 || i > 1)
return 0;
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 :
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
}
/* Subroutine of cpp_classify_number. S points to an integer suffix
"traditional C rejects the \"%.*s\" suffix",
(int) (limit - str), str);
"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
result |= CPP_N_FLOATING;
}
else
#define CPP_N_UNSIGNED 0x1000 /* Properties. */
#define CPP_N_IMAGINARY 0x2000
#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. */
/* Classify a CPP_NUMBER token. The return value is a combination of
the flags from the above sets. */