scc

simple c99 compiler
git clone git://git.simple-cc.org/scc
Log | Files | Refs | Submodules | README | LICENSE

commit 661b5b01217b553c0e0b142ae41bdf9c9b2ac14b
parent b04e1786f2fbbf3976b6d0aba4cc122aefd23bc7
Author: Roberto E. Vargas Caballero <k0ga@shike2.net>
Date:   Thu, 29 Jan 2026 13:35:25 +0100

cc1: Accept digits in macro parameters

The last changes about parsing macro definitions creates a new bug because they
defined identifiers only using alpha and _ characters, but it should accept
digits after the 1st character.

Diffstat:
Msrc/cmd/scc-cc/cc1/cpp.c | 2+-
Atests/cc/execute/0234-macro.c | 34++++++++++++++++++++++++++++++++++
Mtests/cc/execute/scc-tests.lst | 1+
3 files changed, 36 insertions(+), 1 deletion(-)

diff --git a/src/cmd/scc-cc/cc1/cpp.c b/src/cmd/scc-cc/cc1/cpp.c @@ -554,7 +554,7 @@ getdefs(Symbol *args[NR_MACROARG], int nargs, char *buffer, size_t bufsiz) } } else if (c == '_' || isalpha(c)) { token = IDEN; - for (p = input->p; isalpha(*p) || *p == '_'; ++p) + for (p = input->p; isalnum(*p) || *p == '_'; ++p) ; len = p - input->p; if (len > INTIDENTSIZ) { diff --git a/tests/cc/execute/0234-macro.c b/tests/cc/execute/0234-macro.c @@ -0,0 +1,34 @@ +#ifdef __cplusplus +#define FT_STATIC_BYTE_CAST( type, var ) \ + static_cast<type>( static_cast<unsigned char>( var ) ) +#else +#define FT_STATIC_BYTE_CAST( type, var ) (type)(unsigned char)(var) +#endif + +#ifndef FT_IMAGE_TAG + +#define FT_IMAGE_TAG( value, _x1, _x2, _x3, _x4 ) \ + value = ( ( FT_STATIC_BYTE_CAST( unsigned long, _x1 ) << 24 ) | \ + ( FT_STATIC_BYTE_CAST( unsigned long, _x2 ) << 16 ) | \ + ( FT_STATIC_BYTE_CAST( unsigned long, _x3 ) << 8 ) | \ + FT_STATIC_BYTE_CAST( unsigned long, _x4 ) ) + +#endif /* FT_IMAGE_TAG */ + +typedef enum FT_Glyph_Format_ +{ + FT_IMAGE_TAG( FT_GLYPH_FORMAT_NONE, 0, 0, 0, 0 ), + + FT_IMAGE_TAG( FT_GLYPH_FORMAT_COMPOSITE, 'c', 'o', 'm', 'p' ), + FT_IMAGE_TAG( FT_GLYPH_FORMAT_BITMAP, 'b', 'i', 't', 's' ), + FT_IMAGE_TAG( FT_GLYPH_FORMAT_OUTLINE, 'o', 'u', 't', 'l' ), + FT_IMAGE_TAG( FT_GLYPH_FORMAT_PLOTTER, 'p', 'l', 'o', 't' ), + FT_IMAGE_TAG( FT_GLYPH_FORMAT_SVG, 'S', 'V', 'G', ' ' ) + +} FT_Glyph_Format; + +int +main(void) +{ + return 0; +} diff --git a/tests/cc/execute/scc-tests.lst b/tests/cc/execute/scc-tests.lst @@ -224,3 +224,4 @@ 0231-init.c 0232-cppmacro.c 0233-ifelif.c +0234-macro.c