diff options
| author | Ramsay Jones <ramsay@ramsayjones.plus.com> | 2018-11-19 20:49:42 +0000 |
|---|---|---|
| committer | Luc Van Oostenryck <luc.vanoostenryck@gmail.com> | 2018-11-24 18:29:01 +0100 |
| commit | f32b8b2f6e79db2e72c1e57b29da6dd8a94b4478 (patch) | |
| tree | fd9a77c4e53edfb96e1e9f42220bdd68452a0e57 /validation/preprocessor | |
| parent | 24278007c5315d94f76ce550d27192f55cb2840a (diff) | |
| download | sparse-dev-f32b8b2f6e79db2e72c1e57b29da6dd8a94b4478.tar.gz | |
pre-process: print macros containing # and ## correctly
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@ramsayjones.plus.com>
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
Diffstat (limited to 'validation/preprocessor')
| -rw-r--r-- | validation/preprocessor/dump-macros.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/validation/preprocessor/dump-macros.c b/validation/preprocessor/dump-macros.c index 4dbb9620..5a964649 100644 --- a/validation/preprocessor/dump-macros.c +++ b/validation/preprocessor/dump-macros.c @@ -6,6 +6,9 @@ #define DEF xyz #define NYDEF ydef + +#define STRING(x) #x +#define CONCAT(x,y) x ## y /* * check-name: dump-macros * check-command: sparse -E -dD -DIJK=ijk -UNDEF -UNYDEF $file @@ -15,4 +18,6 @@ check-output-pattern(1): #define __CHECKER__ 1 check-output-contains: #define IJK ijk check-output-contains: #define DEF xyz check-output-contains: #define NYDEF ydef +check-output-contains: #define STRING(x) #x +check-output-contains: #define CONCAT(x, y) x ## y */ |
