summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@linux.intel.com>2016-05-09 12:00:19 -0700
committerH. Peter Anvin <hpa@linux.intel.com>2016-05-09 12:00:19 -0700
commit934f0478d409bced70ba1660512d4839cd76c571 (patch)
tree72b06e8ec57909096559451aed65314a2cc5a5c3
parent3d72e45a137dcf5ff014856ea631811200341ad3 (diff)
downloadnasm-934f0478d409bced70ba1660512d4839cd76c571.tar.gz
Fix the handling of pass1 warnings, display control option for warnings
Fix pass1 warnings so they actually display. When issuing suppressible warnings, display the option that controls them, as gcc has been doing for a while. Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
-rw-r--r--nasm.c22
1 files changed, 15 insertions, 7 deletions
diff --git a/nasm.c b/nasm.c
index fc26bba7..bb9e2068 100644
--- a/nasm.c
+++ b/nasm.c
@@ -1953,15 +1953,19 @@ static bool is_suppressed_warning(int severity)
static bool skip_this_pass(int severity)
{
- /* See if it's a pass-one only warning and we're not in pass one. */
+ /* See if it's a pass-specific warning which should be skipped. */
+
if ((severity & ERR_MASK) > ERR_WARNING)
return false;
- if (((severity & ERR_PASS1) && pass0 != 1) ||
- ((severity & ERR_PASS2) && pass0 != 2))
- return true;
- return false;
+ /*
+ * passn is 1 on the very first pass only.
+ * pass0 is 2 on the code-generation (final) pass only.
+ * These are the passes we care about in this case.
+ */
+ return (((severity & ERR_PASS1) && passn != 1) ||
+ ((severity & ERR_PASS2) && pass0 != 2));
}
/**
@@ -2000,14 +2004,18 @@ static void nasm_verror_common(int severity, const char *fmt, va_list args)
break;
}
- vsnprintf(msg, sizeof msg, fmt, args);
+ vsnprintf(msg, sizeof msg - 64, fmt, args);
+ if (severity & ERR_WARN_MASK) {
+ char *p = strchr(msg, '\0');
+ snprintf(p, 64, " [-w+%s]", warnings[WARN_IDX(severity)].name);
+ }
if (!skip_this_pass(severity))
fprintf(error_file, "%s%s\n", pfx, msg);
/*
* Don't suppress this with skip_this_pass(), or we don't get
- * preprocessor warnings in the list file
+ * pass1 or preprocessor warnings in the list file
*/
if ((severity & ERR_MASK) >= ERR_WARNING)
lfmt->error(severity, pfx, msg);