tccpp: remove unwanted space with __VA_ARGS__

reported by "vsfos"
https://lists.gnu.org/archive/html/tinycc-devel/2023-04/msg00007.html
This commit is contained in:
grischka 2023-04-07 00:45:20 +02:00
parent 6a24b762d3
commit 86f3d8e331
3 changed files with 10 additions and 4 deletions

View File

@ -2985,7 +2985,6 @@ static int *macro_arg_subst(Sym **nested_list, const int *macro_str, Sym *args)
} else if (t >= TOK_IDENT) { } else if (t >= TOK_IDENT) {
s = sym_find2(args, t); s = sym_find2(args, t);
if (s) { if (s) {
int l0 = str.len;
st = s->d; st = s->d;
/* if '##' is present before or after, no arg substitution */ /* if '##' is present before or after, no arg substitution */
if (*macro_str == TOK_PPJOIN || t1 == TOK_PPJOIN) { if (*macro_str == TOK_PPJOIN || t1 == TOK_PPJOIN) {
@ -3017,15 +3016,16 @@ static int *macro_arg_subst(Sym **nested_list, const int *macro_str, Sym *args)
} }
st = s->next->d; st = s->next->d;
} }
for(;;) { if (*st <= 0) {
/* expanded to empty string */
tok_str_add(&str, TOK_PLCHLDR);
} else for (;;) {
int t2; int t2;
TOK_GET(&t2, &st, &cval); TOK_GET(&t2, &st, &cval);
if (t2 <= 0) if (t2 <= 0)
break; break;
tok_str_add2(&str, t2, &cval); tok_str_add2(&str, t2, &cval);
} }
if (str.len == l0) /* expanded to empty string */
tok_str_add(&str, TOK_PLCHLDR);
} else { } else {
tok_str_add(&str, t); tok_str_add(&str, t);
} }

View File

@ -29,3 +29,8 @@ __NORETURN
#define X(...) #define X(...)
#define Y(...) 1 __VA_ARGS__ 2 #define Y(...) 1 __VA_ARGS__ 2
Y(X X() ()) Y(X X() ())
#define DDD(A, B) D_ ## B ## _D_ ## A
#define CCC(X, ...) DDD(X, ##__VA_ARGS__)
/* must be D_B_D_A (not D_B _D_A) */
CCC(A,B)

View File

@ -13,3 +13,4 @@ x A y
x y x y
__attribute__((__noreturn__)) __attribute__((__noreturn__))
1 2 1 2
D_B_D_A