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