| @@ -1213,9 +1213,9 @@ static void tok_print(int *str) · 1212 unmodified lines |
| 1213 | ST_FUNC void parse_define(void) | 1213 | ST_FUNC void parse_define(void) |
| 1214 | { | 1214 | { |
| 1215 | Sym *s, *first, **ps; | 1215 | Sym *s, *first, **ps; |
| 1216 | int v, t, varg, is_vaargs, spc; | 1216 | int v, t, varg, is_vaargs, spc, ptok, macro_list_start; |
| 1217 | TokenString str; | 1217 | TokenString str; |
| 1218 | | 1218 | |
| 1219 | v = tok; | 1219 | v = tok; |
| 1220 | if (v < TOK_IDENT) | 1220 | if (v < TOK_IDENT) |
| 1221 | tcc_error("invalid macro name '%s'", get_tok_str(tok, &tokc)); | 1221 | tcc_error("invalid macro name '%s'", get_tok_str(tok, &tokc)); |
| @@ -1254,8 +1254,13 @@ ST_FUNC void parse_define(void) · 32 unmodified lines |
| 1254 | tok_str_new(&str); | 1254 | tok_str_new(&str); |
| 1255 | spc = 2; | 1255 | spc = 2; |
| 1256 | /* EOF testing necessary for '-D' handling */ | 1256 | /* EOF testing necessary for '-D' handling */ |
| | 1257 | ptok = 0; |
| | 1258 | macro_list_start = 1; |
| 1257 | while (tok != TOK_LINEFEED && tok != TOK_EOF) { | 1259 | while (tok != TOK_LINEFEED && tok != TOK_EOF) { |
| 1258 | /* remove spaces around ## and after '#' */ | 1260 | if (!macro_list_start && spc == 2 && tok == TOK_TWOSHARPS) |
| | 1261 | tcc_error("'##' invalid at start of macro"); |
| | 1262 | ptok = tok; |
| | 1263 | /* remove spaces around ## and after '#' */ |
| 1259 | if (TOK_TWOSHARPS == tok) { | 1264 | if (TOK_TWOSHARPS == tok) { |
| 1260 | if (1 == spc) | 1265 | if (1 == spc) |
| 1261 | --str.len; | 1266 | --str.len; |
| @@ -1268,7 +1273,10 @@ ST_FUNC void parse_define(void) · 6 unmodified lines |
| 1268 | tok_str_add2(&str, tok, &tokc); | 1273 | tok_str_add2(&str, tok, &tokc); |
| 1269 | skip: | 1274 | skip: |
| 1270 | next_nomacro_spc(); | 1275 | next_nomacro_spc(); |
| | 1276 | macro_list_start = 0; |
| 1271 | } | 1277 | } |
| | 1278 | if (ptok == TOK_TWOSHARPS) |
| | 1279 | tcc_error("'##' invalid at end of macro"); |
| 1272 | if (spc == 1) | 1280 | if (spc == 1) |
| 1273 | --str.len; /* remove trailing space */ | 1281 | --str.len; /* remove trailing space */ |
| 1274 | tok_str_add(&str, 0); | 1282 | tok_str_add(&str, 0); |