summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@linux.intel.com>2016-02-17 20:47:01 -0800
committerH. Peter Anvin <hpa@linux.intel.com>2016-02-17 20:47:01 -0800
commit4a8d10c1a004ace853dd3019814329065dda5050 (patch)
treed1045bde72086bd3e0e016a416ae2cbebb125899
parentb2bfb580dfac3f793abd83f79df8312902811b49 (diff)
downloadnasm-4a8d10c1a004ace853dd3019814329065dda5050.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. 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 140a6e19..52ac3247 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);
@@ -1872,11 +1873,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);
@@ -1908,11 +1911,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);
@@ -1932,11 +1937,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)];
@@ -1944,6 +1944,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
@@ -1982,9 +1995,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;
@@ -2014,6 +2033,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;
}