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.
This commit is contained in:
parent
1da92cdd93
commit
64f4b00d34
3 changed files with 15 additions and 0 deletions
1
tccpp.c
1
tccpp.c
|
@ -1189,6 +1189,7 @@ ST_FUNC void end_macro(void)
|
||||||
macro_stack = str->prev;
|
macro_stack = str->prev;
|
||||||
macro_ptr = str->prev_ptr;
|
macro_ptr = str->prev_ptr;
|
||||||
file->line_num = str->save_line_num;
|
file->line_num = str->save_line_num;
|
||||||
|
str->len = 0; /* matters if str not alloced, may be tokstr_buf */
|
||||||
if (str->alloc != 0) {
|
if (str->alloc != 0) {
|
||||||
if (str->alloc == 2)
|
if (str->alloc == 2)
|
||||||
str->str = NULL; /* don't free */
|
str->str = NULL; /* don't free */
|
||||||
|
|
12
tests/pp/22.c
Normal file
12
tests/pp/22.c
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
#define TRACE(a,b,c) X a X b X c X
|
||||||
|
#define rettrue(x) 1
|
||||||
|
A rettrue(bla) B
|
||||||
|
TRACE(
|
||||||
|
ARG_1,
|
||||||
|
#if rettrue(bla)
|
||||||
|
ARG_2,
|
||||||
|
#else
|
||||||
|
ARG_2_wrong,
|
||||||
|
#endif
|
||||||
|
ARG_3
|
||||||
|
);
|
2
tests/pp/22.expect
Normal file
2
tests/pp/22.expect
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
A 1 B
|
||||||
|
X ARG_1 X ARG_2 X ARG_3 X;
|
Loading…
Add table
Reference in a new issue