History

Fix macro expansion of empty args.

Reimar Döffinger committed 11 years ago

Commit fb6331e1 parent a6149c64 files · +14 −2Browse files

Unified · Split

4 files
  1. tccpp.c +1 −1
  2. tests/tests2/71_macro_empty_arg.c +9 −0
  3. tests/tests2/71_macro_empty_arg.expect +1 −0
  4. tests/tests2/Makefile +3 −1
tccpp.c+1−1
@@ -2640,7 +2640,7 @@ static int *macro_arg_subst(Sym **nested_list, const int *macro_str, Sym *args) · 2639 unmodified lines
26402640 tok_str_add2(&str, t1, &cval);
26412641 }
26422642 }
2643− } else {
2643+ } else if (*st != TOK_PLCHLDR) {
26442644 /* NOTE: the stream cannot be read when macro
26452645 substituing an argument */
26462646 macro_subst(&str, nested_list, st, NULL);
tests/tests2/71_macro_empty_arg.c+9−0
@@ -0,0 +1,9 @@
1+#include <stdio.h>
2+
3+#define T(a,b,c) a b c
4+
5+int main(void)
6+{
7+ printf("%d", T(1,+,2) T(+,,) T(,2,*) T(,7,) T(,,));
8+ return 0;
9+}
tests/tests2/71_macro_empty_arg.expect+1−0
@@ -0,0 +1 @@
1+17
tests/tests2/Makefile+3−1
@@ -89,7 +89,9 @@ TESTS = \ · 88 unmodified lines
8989 67_macro_concat.test \
9090 68_macro_param_list_err_1.test \
9191 69_macro_param_list_err_2.test \
92− 70_floating_point_literals.test
92+ 70_floating_point_literals.test \
93+ 71_macro_empty_arg.test \
94+
9395
9496 # 34_array_assignment.test -- array assignment is not in C standard
9597