summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@linux.intel.com>2016-02-17 20:47:01 -0800
committerH. Peter Anvin <hpa@zytor.com>2016-03-03 15:22:03 -0800
commitbd464749d1aa2e7b375ba430b2e755a52edbbef0 (patch)
tree67c1aba2cd29887ecc1ada77805b279a5fc7f49a
parentd6d1b658263a035beb592a794184bf2e0ea1ef01 (diff)
downloadnasm-bd464749d1aa2e7b375ba430b2e755a52edbbef0.tar.gz
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>
-rw-r--r--nasm.c58
1 files changed, 41 insertions, 17 deletions
diff --git a/nasm.c b/nasm.c
index 42f1e894..0520500c 100644
--- a/nasm.c
+++ b/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, &currentfile);
- 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, &currentfile);
- 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;
}