History

tccpp: Fix #ifdef in macro args

see testcase. We have to "empty" the macro-stack string on end_macro, as it may be 'tokstr_buf' which is going to be used twice in recursive invocations of macro_subst_tok. The uses aren't overlapping but the first one needs to be properly finalized.

Michael Matz committed 4 years ago

Commit 64f4b001 parent 1da92cd3 files · +15 −0Browse files

Unified · Split

3 files
  1. tccpp.c +1 −0
  2. tests/pp/22.c +12 −0
  3. tests/pp/22.expect +2 −0
tccpp.c+1−0
@@ -1189,6 +1189,7 @@ ST_FUNC void end_macro(void) · 1188 unmodified lines
1189 macro_stack = str->prev;1189 macro_stack = str->prev;
1190 macro_ptr = str->prev_ptr;1190 macro_ptr = str->prev_ptr;
1191 file->line_num = str->save_line_num;1191 file->line_num = str->save_line_num;
1192 str->len = 0; /* matters if str not alloced, may be tokstr_buf */
1192 if (str->alloc != 0) {1193 if (str->alloc != 0) {
1193 if (str->alloc == 2)1194 if (str->alloc == 2)
1194 str->str = NULL; /* don't free */1195 str->str = NULL; /* don't free */
tests/pp/22.c+12−0
@@ -0,0 +1,12 @@
1#define TRACE(a,b,c) X a X b X c X
2#define rettrue(x) 1
3A rettrue(bla) B
4TRACE(
5 ARG_1,
6#if rettrue(bla)
7 ARG_2,
8#else
9 ARG_2_wrong,
10#endif
11 ARG_3
12);
tests/pp/22.expect+2−0
@@ -0,0 +1,2 @@
1A 1 B
2X ARG_1 X ARG_2 X ARG_3 X;

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