mirror of
https://github.com/netwide-assembler/nasm.git
synced 2024-11-21 03:14:19 +08:00
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) <hpa@zytor.com>
This commit is contained in:
parent
4431b268ae
commit
42b9579f90
18
asm/nasm.c
18
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;
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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 */
|
||||
|
23
test/note.asm
Normal file
23
test/note.asm
Normal file
@ -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
|
Loading…
Reference in New Issue
Block a user