On Wed, Feb 4, 2015 at 12:01 AM, Christopher Li <sparse@xxxxxxxxxxx> wrote: > > When the lexer process the escape char, you did not know the string > is wide char or not. That can be changed after the macro expansion. With that in mind, we can't actually perform the escape char substitution before the pre-processor stage. Here is an untested patch adding the immutable string to macro body. I need to double check if the macro arguments needs it as well. Can you guys try it on the test case you have? Thanks Chris diff --git a/char.c b/char.c index 08ca223..7f86b8a 100644 --- a/char.c +++ b/char.c @@ -123,7 +123,7 @@ struct token *get_string_constant(struct token *token, struct expression *expr) len = MAX_STRING; } - if (len >= string->length) /* can't cannibalize */ + if (string->immutable || len >= string->length) /* can't cannibalize */ string = __alloc_string(len+1); string->length = len+1; memcpy(string->data, buffer, len); diff --git a/pre-process.c b/pre-process.c index 1aa3d2c..57d84b9 100644 --- a/pre-process.c +++ b/pre-process.c @@ -1259,8 +1259,16 @@ static struct token *parse_expansion(struct token *expansion, struct token *argl } else { try_arg(token, TOKEN_MACRO_ARGUMENT, arglist); } - if (token_type(token) == TOKEN_ERROR) + switch (token_type(token)) { + case TOKEN_ERROR: goto Earg; + + case TOKEN_STRING: + case TOKEN_WIDE_STRING: + token->string->immutable = 1; + default: + ; + } } token = alloc_token(&expansion->pos); token_type(token) = TOKEN_UNTAINT; diff --git a/token.h b/token.h index 8dbd80f..af66b2b 100644 --- a/token.h +++ b/token.h @@ -164,7 +164,8 @@ enum special_token { }; struct string { - unsigned int length; + unsigned int length:31; + unsigned int immutable:1; char data[]; }; -- To unsubscribe from this list: send the line "unsubscribe linux-sparse" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html