1
0
mirror of https://github.com/cc65/cc65.git synced 2025-08-08 22:25:28 +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

View File

@@ -2640,6 +2640,18 @@ static void DoDefine (void)
goto Error_Handler; goto Error_Handler;
} }
NextChar (); 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 /* 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' */ /* Ensure the buffer is terminated with a '\0' */
SB_Terminate (&Buf); SB_Terminate (&Buf);
if (SkipWhitespace (0) != 0 || CurC == '\0') { if (SB_GetLen (&Buf) > 0) {
const char* Str = SB_GetConstBuf (&Buf); const char* Str = SB_GetConstBuf (&Buf);
if (Str[0] == '\0') { if (Str[0] == '\0') {
PPWarning ("#line directive interprets number as decimal, not octal"); PPWarning ("#line directive interprets number as decimal, not octal");
@@ -2929,9 +2941,10 @@ static unsigned GetLineDirectiveNum (void)
} }
} }
} else { } else {
PPError ("#line directive requires a simple decimal digit sequence"); PPError ("#line directive requires a decimal digit sequence");
ClearLine (); ClearLine ();
} }
SkipWhitespace (0);
/* Done with the buffer */ /* Done with the buffer */
SB_Done (&Buf); SB_Done (&Buf);