Perhaps a better fix would be to ensure tok is set to TOK_EOF rather than 0 at the end of a macro stream. This partially fixes test2 of the examples given in: http://lists.nongnu.org/archive/html/tinycc-devel/2015-05/msg00002.html It's still failing, but at least it's not running out of memory now.
Unified · Split
| @@ -2930,8 +2930,9 @@ static int macro_subst_tok(TokenString *tok_str, · 2929 unmodified lines | ||
| 2930 | 2930 | /* NOTE: non zero sa->t indicates VA_ARGS */ |
| 2931 | 2931 | while ((parlevel > 0 || |
| 2932 | 2932 | (tok != ')' && |
| 2933 | − (tok != ',' || sa->type.t))) && | |
| 2934 | − tok != -1) { | |
| 2933 | + (tok != ',' || sa->type.t)))) { | |
| 2934 | + if (tok == TOK_EOF || tok == 0) | |
| 2935 | + break; | |
| 2935 | 2936 | if (tok == '(') |
| 2936 | 2937 | parlevel++; |
| 2937 | 2938 | else if (tok == ')') |