mirror of
https://github.com/netwide-assembler/nasm.git
synced 2025-04-12 18:40:23 +08:00
Output preprocessor warnings to the listing file
Most preprocessor warnings are ERR_PASS1, but we want to see them in the listing file too. If we make it to the code-generation pass, ignore ERR_PASS* for the purpose of emitting warnings to the list file. While we are at it, allow ERR_DEBUG to specify ERR_PASS* too. From master branch checkin 4a8d10c1a004ace853dd3019814329065dda5050 Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
This commit is contained in:
parent
d6d1b65826
commit
bd464749d1
58
nasm.c
58
nasm.c
@ -79,6 +79,7 @@ static iflag_t get_cpu(char *cpu_str);
|
||||
static void parse_cmdline(int, char **);
|
||||
static void assemble_file(char *, StrList **);
|
||||
static bool is_suppressed_warning(int severity);
|
||||
static bool skip_this_pass(int severity);
|
||||
static void nasm_verror_gnu(int severity, const char *fmt, va_list args);
|
||||
static void nasm_verror_vc(int severity, const char *fmt, va_list args);
|
||||
static void nasm_verror_common(int severity, const char *fmt, va_list args);
|
||||
@ -1869,11 +1870,13 @@ static void nasm_verror_gnu(int severity, const char *fmt, va_list ap)
|
||||
if (!(severity & ERR_NOFILE))
|
||||
src_get(&lineno, ¤tfile);
|
||||
|
||||
if (currentfile) {
|
||||
fprintf(error_file, "%s:%"PRId32": ", currentfile, lineno);
|
||||
nasm_free(currentfile);
|
||||
} else {
|
||||
fputs("nasm: ", error_file);
|
||||
if (!skip_this_pass(severity)) {
|
||||
if (currentfile) {
|
||||
fprintf(error_file, "%s:%"PRId32": ", currentfile, lineno);
|
||||
nasm_free(currentfile);
|
||||
} else {
|
||||
fputs("nasm: ", error_file);
|
||||
}
|
||||
}
|
||||
|
||||
nasm_verror_common(severity, fmt, ap);
|
||||
@ -1905,11 +1908,13 @@ static void nasm_verror_vc(int severity, const char *fmt, va_list ap)
|
||||
if (!(severity & ERR_NOFILE))
|
||||
src_get(&lineno, ¤tfile);
|
||||
|
||||
if (currentfile) {
|
||||
fprintf(error_file, "%s(%"PRId32") : ", currentfile, lineno);
|
||||
nasm_free(currentfile);
|
||||
} else {
|
||||
fputs("nasm: ", error_file);
|
||||
if (!skip_this_pass(severity)) {
|
||||
if (currentfile) {
|
||||
fprintf(error_file, "%s(%"PRId32") : ", currentfile, lineno);
|
||||
nasm_free(currentfile);
|
||||
} else {
|
||||
fputs("nasm: ", error_file);
|
||||
}
|
||||
}
|
||||
|
||||
nasm_verror_common(severity, fmt, ap);
|
||||
@ -1929,11 +1934,6 @@ static bool is_suppressed_warning(int severity)
|
||||
if ((severity & ERR_MASK) != ERR_WARNING)
|
||||
return false;
|
||||
|
||||
/* See if it's a pass-one only warning and we're not in pass one. */
|
||||
if (((severity & ERR_PASS1) && pass0 != 1) ||
|
||||
((severity & ERR_PASS2) && pass0 != 2))
|
||||
return true;
|
||||
|
||||
/* Might be a warning but suppresed explicitly */
|
||||
if (severity & ERR_WARN_MASK)
|
||||
return !warning_on[WARN_IDX(severity)];
|
||||
@ -1941,6 +1941,19 @@ static bool is_suppressed_warning(int severity)
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool skip_this_pass(int severity)
|
||||
{
|
||||
/* See if it's a pass-one only warning and we're not in pass one. */
|
||||
if ((severity & ERR_MASK) > ERR_WARNING)
|
||||
return false;
|
||||
|
||||
if (((severity & ERR_PASS1) && pass0 != 1) ||
|
||||
((severity & ERR_PASS2) && pass0 != 2))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* common error reporting
|
||||
* This is the common back end of the error reporting schemes currently
|
||||
@ -1979,9 +1992,15 @@ static void nasm_verror_common(int severity, const char *fmt, va_list args)
|
||||
|
||||
vsnprintf(msg, sizeof msg, fmt, args);
|
||||
|
||||
fprintf(error_file, "%s%s\n", pfx, msg);
|
||||
if (!skip_this_pass(severity))
|
||||
fprintf(error_file, "%s%s\n", pfx, msg);
|
||||
|
||||
nasmlist->error(severity, pfx, msg);
|
||||
/*
|
||||
* Don't suppress this with skip_this_pass(), or we don't get
|
||||
* preprocessor warnings in the list file
|
||||
*/
|
||||
if ((severity & ERR_MASK) >= ERR_WARNING)
|
||||
nasmlist->error(severity, pfx, msg);
|
||||
|
||||
if (severity & ERR_USAGE)
|
||||
want_usage = true;
|
||||
@ -2011,6 +2030,11 @@ static void nasm_verror_common(int severity, const char *fmt, va_list args)
|
||||
case ERR_PANIC:
|
||||
fflush(NULL);
|
||||
/* abort(); */ /* halt, catch fire, and dump core */
|
||||
if (ofile) {
|
||||
fclose(ofile);
|
||||
remove(outname);
|
||||
ofile = NULL;
|
||||
}
|
||||
exit(3);
|
||||
break;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user