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
34243424 for(;;) {
34253425 do {
34263426 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);
34283429 empty_arg:
34293430 /* handle '()' case */
34303431 if (!args && !sa && tok == ')')
tests/tcctest.c+5−0
@@ -115,6 +115,9 @@ static int onetwothree = 123; · 114 unmodified lines
115115
116116 #define MACRO_NOARGS()
117117
118+#define TEST_CALL(f, ...) f(__VA_ARGS__)
119+#define TEST_CONST() 123
120+
118121 #define AAA 3
119122 #undef AAA
120123 #define AAA 4
@@ -223,6 +226,8 @@ void macro_test(void) · 102 unmodified lines
223226
224227 MACRO_NOARGS();
225228
229+ printf("%d\n", TEST_CALL(TEST_CONST));
230+
226231 /* not strictly preprocessor, but we test it there */
227232 #ifdef C99_MACROS
228233 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