Fix unchecked integer or floating point suffixes.
This commit is contained in:
@@ -558,6 +558,7 @@ static void NumericConst (void)
|
|||||||
unsigned DigitVal;
|
unsigned DigitVal;
|
||||||
scan_t IVal; /* Scanned value. */
|
scan_t IVal; /* Scanned value. */
|
||||||
int Overflow;
|
int Overflow;
|
||||||
|
unsigned SuffixStart;
|
||||||
|
|
||||||
/* Get the pp-number first, then parse on it */
|
/* Get the pp-number first, then parse on it */
|
||||||
CopyPPNumber (&Src);
|
CopyPPNumber (&Src);
|
||||||
@@ -641,6 +642,7 @@ static void NumericConst (void)
|
|||||||
** possible to convert the data to unsigned long even if the IT_ULONG
|
** possible to convert the data to unsigned long even if the IT_ULONG
|
||||||
** flag were not set, but we are not doing that.
|
** flag were not set, but we are not doing that.
|
||||||
*/
|
*/
|
||||||
|
SuffixStart = SB_GetIndex (&Src);
|
||||||
if (toupper (SB_Peek (&Src)) == 'U') {
|
if (toupper (SB_Peek (&Src)) == 'U') {
|
||||||
/* Unsigned type */
|
/* Unsigned type */
|
||||||
SB_Skip (&Src);
|
SB_Skip (&Src);
|
||||||
@@ -661,11 +663,6 @@ static void NumericConst (void)
|
|||||||
Types = IT_ULONG;
|
Types = IT_ULONG;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (SB_Peek (&Src) != '\0') {
|
|
||||||
Error ("Invalid suffix \"%s\" on integer constant",
|
|
||||||
SB_GetConstBuf (&Src) + SB_GetIndex (&Src));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Base == 10) {
|
if (Base == 10) {
|
||||||
/* Decimal constants are of any type but uint */
|
/* Decimal constants are of any type but uint */
|
||||||
Types = IT_INT | IT_LONG | IT_ULONG;
|
Types = IT_INT | IT_LONG | IT_ULONG;
|
||||||
@@ -676,6 +673,12 @@ static void NumericConst (void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Check for remaining suffix characters */
|
||||||
|
if (SB_Peek (&Src) != '\0') {
|
||||||
|
Error ("Invalid suffix \"%s\" on integer constant",
|
||||||
|
SB_GetConstBuf (&Src) + SuffixStart);
|
||||||
|
}
|
||||||
|
|
||||||
/* Check the range to determine the type */
|
/* Check the range to determine the type */
|
||||||
if (IVal > 0x7FFF) {
|
if (IVal > 0x7FFF) {
|
||||||
/* Out of range for int */
|
/* Out of range for int */
|
||||||
@@ -806,16 +809,17 @@ static void NumericConst (void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Check for a suffix and determine the type of the constant */
|
/* Check for a suffix and determine the type of the constant */
|
||||||
|
SuffixStart = SB_GetIndex (&Src);
|
||||||
if (toupper (SB_Peek (&Src)) == 'F') {
|
if (toupper (SB_Peek (&Src)) == 'F') {
|
||||||
SB_Skip (&Src);
|
SB_Skip (&Src);
|
||||||
NextTok.Type = type_float;
|
NextTok.Type = type_float;
|
||||||
} else {
|
} else {
|
||||||
if (SB_Peek (&Src) != '\0') {
|
|
||||||
Error ("Invalid suffix \"%s\" on floating constant",
|
|
||||||
SB_GetConstBuf (&Src) + SB_GetIndex (&Src));
|
|
||||||
}
|
|
||||||
NextTok.Type = type_double;
|
NextTok.Type = type_double;
|
||||||
}
|
}
|
||||||
|
if (SB_Peek (&Src) != '\0') {
|
||||||
|
Error ("Invalid suffix \"%s\" on floating constant",
|
||||||
|
SB_GetConstBuf (&Src) + SuffixStart);
|
||||||
|
}
|
||||||
|
|
||||||
/* Set the value and the token */
|
/* Set the value and the token */
|
||||||
NextTok.FVal = FVal;
|
NextTok.FVal = FVal;
|
||||||
|
|||||||
Reference in New Issue
Block a user