1
0
mirror of https://github.com/cc65/cc65.git synced 2024-12-26 08:32:00 +00:00

Merge pull request #2518 from kugelfuhr/kugelfuhr/fix-2515

Fix minor preprocessor problems
This commit is contained in:
Bob Andrews 2024-09-13 17:53:20 +02:00 committed by GitHub
commit 7260c10062
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -2640,6 +2640,18 @@ static void DoDefine (void)
goto Error_Handler;
}
NextChar ();
} else {
/* Object like macro. Check ISO/IEC 9899:1999 (E) 6.10.3p3:
** "There shall be white-space between the identifier and the
** replacement list in the definition of an object-like macro."
** Note: C89 doesn't have this constraint.
*/
if (Std == STD_C99 && !IsSpace (CurC)) {
PPWarning ("ISO C99 requires whitespace after the macro name");
}
}
/* Remove whitespace and comments from the line, store the preprocessed
@ -2913,7 +2925,7 @@ static unsigned GetLineDirectiveNum (void)
/* Ensure the buffer is terminated with a '\0' */
SB_Terminate (&Buf);
if (SkipWhitespace (0) != 0 || CurC == '\0') {
if (SB_GetLen (&Buf) > 0) {
const char* Str = SB_GetConstBuf (&Buf);
if (Str[0] == '\0') {
PPWarning ("#line directive interprets number as decimal, not octal");
@ -2929,9 +2941,10 @@ static unsigned GetLineDirectiveNum (void)
}
}
} else {
PPError ("#line directive requires a simple decimal digit sequence");
PPError ("#line directive requires a decimal digit sequence");
ClearLine ();
}
SkipWhitespace (0);
/* Done with the buffer */
SB_Done (&Buf);