On 12/8/23 20:47, Patrick Pelissier wrote:
Hi,
I think I have found an issue in TCC preprocessing.
The program below produces the following output when runs with tcc -E:
, USER
, USER_COMP_CORE
whereas I would have expected 1 more line:
, USER
, USER_COMP_CORE
, USER_COMP_CORE
(Tested with GIT 81a32ec305ee871d8129978bf3d57bc108bec46b)
The program is a little bit long so it is available here:
https://gist.github.com/P-p-H-d/aeb690c7ed396b57a84f9a5fc83e10c0
I did some debugging can came up with attached patch.
The testcase probably has to go into the tests/pp directory.
I am not sure this is the correct fix. So I am not committing it yet.
Herman
diff --git a/tccpp.c b/tccpp.c
index ae9ae00..9ad9516 100644
--- a/tccpp.c
+++ b/tccpp.c
@@ -3023,7 +3023,8 @@ static int *macro_arg_subst(Sym **nested_list, const int
*macro_str, Sym *args)
}
if (*st <= 0) {
/* expanded to empty string */
- tok_str_add(&str, TOK_PLCHLDR);
+ if (str.len && str.str[str.len - 1] != TOK_PLCHLDR)
+ tok_str_add(&str, TOK_PLCHLDR);
} else for (;;) {
int t2;
TOK_GET(&t2, &st, &cval);
_______________________________________________
Tinycc-devel mailing list
Tinycc-devel@nongnu.org
https://lists.nongnu.org/mailman/listinfo/tinycc-devel