From 42b9579f90d26d2123036cbab9ca8c20226423d3 Mon Sep 17 00:00:00 2001 From: "H. Peter Anvin (Intel)" Date: Wed, 27 Jun 2018 22:03:01 -0700 Subject: preproc: add new %note directive Add a new %note directive to issue a note into the list file without printing a message. The difference between %note and a comment is that a %note will be issued with single-line macros expanded, and will be issued even if it occurs inside a .nolist macro. Signed-off-by: H. Peter Anvin (Intel) --- asm/nasm.c | 18 ++++++++++++++---- asm/pptok.dat | 3 ++- asm/preproc.c | 7 +++++++ include/error.h | 7 ++++--- test/note.asm | 23 +++++++++++++++++++++++ 5 files changed, 50 insertions(+), 8 deletions(-) create mode 100644 test/note.asm diff --git a/asm/nasm.c b/asm/nasm.c index 55e4a8cf..e1e3eff0 100644 --- a/asm/nasm.c +++ b/asm/nasm.c @@ -1801,6 +1801,12 @@ static bool skip_this_pass(int severity) if ((severity & ERR_MASK) > ERR_NONFATAL) return false; + /* + * We *never* print a message for ERR_NOTE. + */ + if ((severity & ERR_MASK) == ERR_NOTE) + return true; + /* * passn is 1 on the very first pass only. * pass0 is 2 on the code-generation (final) pass only. @@ -1826,6 +1832,12 @@ static void nasm_verror_common(int severity, const char *fmt, va_list args) const char *pfx; switch (severity & (ERR_MASK|ERR_NO_SEVERITY)) { + case ERR_NOTE: + pfx = "note: "; + break; + case ERR_DEBUG: + pfx = "debug: "; + break; case ERR_WARNING: pfx = "warning: "; break; @@ -1838,9 +1850,6 @@ static void nasm_verror_common(int severity, const char *fmt, va_list args) case ERR_PANIC: pfx = "panic: "; break; - case ERR_DEBUG: - pfx = "debug: "; - break; default: pfx = ""; break; @@ -1861,7 +1870,7 @@ static void nasm_verror_common(int severity, const char *fmt, va_list args) /* * Don't suppress this with skip_this_pass(), or we don't get - * pass1 or preprocessor warnings in the list file + * pass1 or preprocessor warnings or notes in the list file */ lfmt->error(severity, pfx, msg); @@ -1874,6 +1883,7 @@ static void nasm_verror_common(int severity, const char *fmt, va_list args) preproc->error_list_macros(severity); switch (severity & ERR_MASK) { + case ERR_NOTE: case ERR_DEBUG: /* no further action, by definition */ break; diff --git a/asm/pptok.dat b/asm/pptok.dat index a2c64d0a..7bb85280 100644 --- a/asm/pptok.dat +++ b/asm/pptok.dat @@ -1,6 +1,6 @@ ## -------------------------------------------------------------------------- ## -## Copyright 1996-2016 The NASM Authors - All Rights Reserved +## Copyright 1996-2018 The NASM Authors - All Rights Reserved ## See the file AUTHORS included with the NASM distribution for ## the specific copyright holders. ## @@ -76,6 +76,7 @@ %line %local %macro +%note %pathsearch %pop %pragma diff --git a/asm/preproc.c b/asm/preproc.c index 8e1e6369..0a6e0fa6 100644 --- a/asm/preproc.c +++ b/asm/preproc.c @@ -2735,6 +2735,9 @@ static int do_directive(Token *tline, char **output) case PP_WARNING: severity = ERR_WARNING|ERR_WARN_USER; goto issue_error; + case PP_NOTE: + severity = ERR_NOTE; + goto issue_error; issue_error: { @@ -2759,6 +2762,10 @@ issue_error: nasm_free(p); } free_tlist(origline); + + if (severity == ERR_NOTE) + lfmt->drop(); /* Suppress printing the actual %note */ + return DIRECTIVE_FOUND; } diff --git a/include/error.h b/include/error.h index 139400db..2f21b102 100644 --- a/include/error.h +++ b/include/error.h @@ -63,9 +63,10 @@ static inline vefunc nasm_set_verror(vefunc ve) * argument to an efunc. */ -#define ERR_DEBUG 0x00000000 /* put out debugging message */ -#define ERR_WARNING 0x00000001 /* warn only: no further action */ -#define ERR_NONFATAL 0x00000002 /* terminate assembly after phase */ +#define ERR_NOTE 0x00000000 /* note in the list file only */ +#define ERR_DEBUG 0x00000001 /* put out debugging message */ +#define ERR_WARNING 0x00000002 /* warn only: no further action */ +#define ERR_NONFATAL 0x00000003 /* terminate assembly after phase */ #define ERR_FATAL 0x00000006 /* instantly fatal: exit with error */ #define ERR_PANIC 0x00000007 /* internal error: panic instantly * and dump core for reference */ diff --git a/test/note.asm b/test/note.asm new file mode 100644 index 00000000..c1ba2bb6 --- /dev/null +++ b/test/note.asm @@ -0,0 +1,23 @@ + bits 32 +%define bluttan 66h +foo: + db bluttan +%warning "bluttan" = bluttan + db 67h + db 60000,60000 +%note "bluttan" = bluttan + nop + +%macro warnalot 0.nolist + db 60000,60000 + db 60000,60000 +%endmacro + + warnalot + +%macro warnalotl 0 + db 60000,60000 + db 60000,60000 +%endmacro + + warnalotl -- cgit v1.2.1