From f13f2cb6196ec0dc2d091c64e6f87cd1f5c5aead Mon Sep 17 00:00:00 2001 From: Gorilla Sapiens Date: Sat, 3 May 2025 02:36:44 +0000 Subject: [PATCH] fixes issue #2637 --- src/cc65/preproc.c | 3 ++- test/misc/Makefile | 6 ++++++ test/misc/bug2637.c | 15 +++++++++++++++ test/misc/bug2637.ref | 0 4 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 test/misc/bug2637.c create mode 100644 test/misc/bug2637.ref diff --git a/src/cc65/preproc.c b/src/cc65/preproc.c index d033520b8..5cdec3142 100644 --- a/src/cc65/preproc.c +++ b/src/cc65/preproc.c @@ -2647,8 +2647,9 @@ static void DoDefine (void) ** "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. + ** Note: if there is no replacement list, a space is not required. */ - if (Std == STD_C99 && !IsSpace (CurC)) { + if (Std == STD_C99 && !IsSpace (CurC) && CurC != 0) { PPWarning ("ISO C99 requires whitespace after the macro name"); } diff --git a/test/misc/Makefile b/test/misc/Makefile index ebae0964e..f5225b14b 100644 --- a/test/misc/Makefile +++ b/test/misc/Makefile @@ -110,6 +110,12 @@ $(WORKDIR)/bug2515.$1.$2.prg: bug2515.c | $(WORKDIR) $(NOT) $(CC65) -t sim$2 -$1 -o $$(@:.prg=.s) $$< 2>$(WORKDIR)/bug2515.$1.$2.out $(ISEQUAL) $(WORKDIR)/bug2515.$1.$2.out bug2515.ref +# should not issue any warnings in C99 mode +$(WORKDIR)/bug2637.$1.$2.prg: bug2637.c | $(WORKDIR) + $(if $(QUIET),echo misc/bug2637.$1.$2.prg) + $(CC65) --standard c99 -t sim$2 -$1 -o $$(@:.prg=.s) $$< 2>$(WORKDIR)/bug2637.$1.$2.out + $(ISEQUAL) $(WORKDIR)/bug2637.$1.$2.out bug2637.ref + # this one requires -Werror $(WORKDIR)/bug1768.$1.$2.prg: bug1768.c | $(WORKDIR) $(if $(QUIET),echo misc/bug1768.$1.$2.prg) diff --git a/test/misc/bug2637.c b/test/misc/bug2637.c new file mode 100644 index 000000000..f6b716465 --- /dev/null +++ b/test/misc/bug2637.c @@ -0,0 +1,15 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include + +// compile with --standard c99 +int main() +{ + return 0; +} diff --git a/test/misc/bug2637.ref b/test/misc/bug2637.ref new file mode 100644 index 000000000..e69de29bb