for example #define LBL(name) _ ## name ## : LBL(main) will give two tokens '_main' and ':' and the warning
Unified · Split
| @@ -3219,7 +3219,7 @@ static int macro_subst_tok( · 3218 unmodified lines | ||
| 3219 | 3219 | static int paste_tokens(int t1, CValue *v1, int t2, CValue *v2) |
| 3220 | 3220 | { |
| 3221 | 3221 | CString cstr; |
| 3222 | − int n; | |
| 3222 | + int n, ret = 1; | |
| 3223 | 3223 | |
| 3224 | 3224 | cstr_new(&cstr); |
| 3225 | 3225 | if (t1 != TOK_PLCHLDR) |
| @@ -3237,15 +3237,15 @@ static int paste_tokens(int t1, CValue *v1, int t2, CValue *v2) · 11 unmodified lines | ||
| 3237 | 3237 | break; |
| 3238 | 3238 | if (is_space(tok)) |
| 3239 | 3239 | continue; |
| 3240 | − tcc_warning("pasting <%.*s> and <%s> does not give a valid preprocessing token", | |
| 3241 | − n, cstr.data, (char*)cstr.data + n); | |
| 3240 | + tcc_warning("pasting \"%.*s\" and \"%s\" does not give a valid" | |
| 3241 | + " preprocessing token", n, cstr.data, (char*)cstr.data + n); | |
| 3242 | + ret = 0; | |
| 3242 | 3243 | break; |
| 3243 | 3244 | } |
| 3244 | 3245 | tcc_close(); |
| 3245 | − | |
| 3246 | 3246 | //printf("paste <%s>\n", (char*)cstr.data); |
| 3247 | 3247 | cstr_free(&cstr); |
| 3248 | − return 0; | |
| 3248 | + return ret; | |
| 3249 | 3249 | } |
| 3250 | 3250 | |
| 3251 | 3251 | /* handle the '##' operator. Return NULL if no '##' seen. Otherwise |
| @@ -3284,13 +3284,15 @@ static inline int *macro_twosharps(const int *ptr0) · 32 unmodified lines | ||
| 3284 | 3284 | /* given 'a##b', remove nosubsts preceding 'b' */ |
| 3285 | 3285 | while ((t1 = *++ptr) == TOK_NOSUBST) |
| 3286 | 3286 | ; |
| 3287 | − if (t1 && t1 != TOK_TWOSHARPS | |
| 3288 | − && t1 != ':') /* 'a##:' don't build a new token */ | |
| 3289 | − { | |
| 3287 | + if (t1 && t1 != TOK_TWOSHARPS) { | |
| 3290 | 3288 | TOK_GET(&t1, &ptr, &cv1); |
| 3291 | 3289 | if (t != TOK_PLCHLDR || t1 != TOK_PLCHLDR) { |
| 3292 | − paste_tokens(t, &cval, t1, &cv1); | |
| 3293 | − t = tok, cval = tokc; | |
| 3290 | + if (paste_tokens(t, &cval, t1, &cv1)) { | |
| 3291 | + t = tok, cval = tokc; | |
| 3292 | + } else { | |
| 3293 | + tok_str_add2(¯o_str1, t, &cval); | |
| 3294 | + t = t1, cval = cv1; | |
| 3295 | + } | |
| 3294 | 3296 | } |
| 3295 | 3297 | } |
| 3296 | 3298 | } |