On Mon, Nov 19, 2018 at 08:49:42PM +0000, Ramsay Jones wrote: > > The dump_macro() function fails to correctly output the definitions of > macros that contain the string operator '#', the concatenation operator > '##' and any macro parameter in the definition token list. For example, > the following macros: > > #define STRING(x) #x > #define CONCAT(x,y) x ## y > > are output like so: > > #define STRING(x) unhandled token type '21' > #define CONCAT(x, y) unhandled token type '22' unhandled token type '23' unhandled token type '22' > > Add the code necessary to handle those token types to the dump_macros() > function and add the above macros to the 'dump-macros.c' test file. > > Signed-off-by: Ramsay Jones <ramsay@xxxxxxxxxxxxxxxxxxxx> > --- > pre-process.c | 7 +++++++ > validation/preprocessor/dump-macros.c | 5 +++++ > 2 files changed, 12 insertions(+) > > diff --git a/pre-process.c b/pre-process.c > index 8abd5e6..eca7ab5 100644 > --- a/pre-process.c > +++ b/pre-process.c > @@ -2196,6 +2196,13 @@ static void dump_macro(struct symbol *sym) > switch (token_type(token)) { > case TOKEN_UNTAINT: > break; > + case TOKEN_STR_ARGUMENT: > + printf("#%s", show_token(args[token->argnum])); > + break; > + case TOKEN_CONCAT: > + printf("## "); > + break; > + case TOKEN_QUOTED_ARGUMENT: > case TOKEN_MACRO_ARGUMENT: > token = args[token->argnum]; > /* fall-through */ I'll squash the following in as it will facilitate some later patches: switch (token_type(token)) { case TOKEN_UNTAINT: break; - case TOKEN_STR_ARGUMENT: - printf("#%s", show_token(args[token->argnum])); - break; case TOKEN_CONCAT: printf("## "); break; + case TOKEN_STR_ARGUMENT: + printf("#"); + /* fall-through */ case TOKEN_QUOTED_ARGUMENT: case TOKEN_MACRO_ARGUMENT: token = args[token->argnum]; Best regards, -- Luc