History

Fix macro processing

The code: printf("%d\n", CALL(CONST)); did not work because we did not check for TOK_PLCHLDR.

herman ten brugge committed 5 years ago

Commit 03781681 parent 3564c472 files · +7 −1Browse files

Unified · Split

2 files
  1. tccpp.c +2 −1
  2. tests/tcctest.c +5 −0
tccpp.c+2−1
@@ -3424,7 +3424,8 @@ static int macro_subst_tok( · 3423 unmodified lines
3424 for(;;) {3424 for(;;) {
3425 do {3425 do {
3426 next_argstream(nested_list, NULL);3426 next_argstream(nested_list, NULL);
3427 } while (is_space(tok) || TOK_LINEFEED == tok);3427 } while (tok == TOK_PLCHLDR || is_space(tok) ||
3428 TOK_LINEFEED == tok);
3428 empty_arg:3429 empty_arg:
3429 /* handle '()' case */3430 /* handle '()' case */
3430 if (!args && !sa && tok == ')')3431 if (!args && !sa && tok == ')')
tests/tcctest.c+5−0
@@ -115,6 +115,9 @@ static int onetwothree = 123; · 114 unmodified lines
115 115
116#define MACRO_NOARGS()116#define MACRO_NOARGS()
117 117
118#define TEST_CALL(f, ...) f(__VA_ARGS__)
119#define TEST_CONST() 123
120
118#define AAA 3121#define AAA 3
119#undef AAA122#undef AAA
120#define AAA 4123#define AAA 4
@@ -223,6 +226,8 @@ void macro_test(void) · 102 unmodified lines
223 226
224 MACRO_NOARGS();227 MACRO_NOARGS();
225 228
229 printf("%d\n", TEST_CALL(TEST_CONST));
230
226 /* not strictly preprocessor, but we test it there */231 /* not strictly preprocessor, but we test it there */
227#ifdef C99_MACROS232#ifdef C99_MACROS
228 printf("__func__ = %s\n", __func__);233 printf("__func__ = %s\n", __func__);

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t