[Nasm-bugs] [Bug 3392632] [Feature request] [Patch] Add label-no-colon warning
noreply-nasm at dev.nasm.us
noreply-nasm at dev.nasm.us
Fri Nov 22 04:47:32 PST 2019
https://bugzilla.nasm.us/show_bug.cgi?id=3392632
C. Masloch <pushbx at ulukai.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |pushbx at ulukai.org
--- Comment #1 from C. Masloch <pushbx at ulukai.org> ---
For the record, here is my patch to parser.c from my old fork, as of 2010-12-19
20:03:25 +0100:
@@ -218,8 +218,8 @@
}
if (i != TOKEN_ID && i != TOKEN_INSN && i != TOKEN_PREFIX &&
(i != TOKEN_REG || (REG_SREG & ~nasm_reg_flags[tokval.t_integer]))) {
- nasm_error(ERR_NONFATAL, "label or instruction expected"
- " at start of line");
+ nasm_error(ERR_NONFATAL, (i == ':' ? "label expected in front of
colon"
+ : "label or instruction expected at start of line") );
result->opcode = I_none;
return result;
}
@@ -231,9 +231,24 @@
i = stdscan(NULL, &tokval);
if (i == ':') { /* skip over the optional colon */
i = stdscan(NULL, &tokval);
- } else if (i == 0) {
- nasm_error(ERR_WARNING | ERR_WARN_OL | ERR_PASS1,
- "label alone on a line without a colon might be in error");
+ } else if (i != TOKEN_INSN || tokval.t_integer != I_EQU) {
+ /*
+ * If the OL warning is suppressed, the LNC warning is displayed
+ * in OL cases too (because OL is a subset of LNC).
+ * If the OL warning displays, and the LNC warning would display
+ * and be treated as an error, then OL is treated as an error
+ * regardless its actual state.
+ */
+ if (i == 0 && !nasm_is_suppressed_warning(ERR_WARNING |
ERR_WARN_OL | ERR_PASS1))
+ nasm_error((nasm_is_warning_error(ERR_WARNING | ERR_WARN_LNC |
ERR_PASS1)
+ ? (ERR_WARNING | ERR_WARN_LNC | ERR_PASS1)
+ : (ERR_WARNING | ERR_WARN_OL | ERR_PASS1)),
+ "label `%s' alone on a line without a colon",
+ result->label);
+ else
+ nasm_error(ERR_WARNING | ERR_WARN_LNC | ERR_PASS1,
+ "label `%s' not followed by a colon",
+ result->label);
}
if (i != TOKEN_INSN || tokval.t_integer != I_EQU) {
/*
This is the part of the patch to nasm.c that implements the functions
nasm_is_suppressed_warning and nasm_is_warning_error:
@@ -1883,8 +2014,14 @@
* @param severity the severity of the warning or error
* @return true if we should abort error/warning printing
*/
-static bool is_suppressed_warning(int severity)
+bool nasm_is_suppressed_warning(int severity)
{
+ if ( (severity & ERR_MASK) == ERR_INFO
+ && ( ((severity & ERR_PASS1) && pass0 != 1)
+ || ((severity & ERR_PASS2) && pass0 != 2)
+ )
+ )
+ return true;
/*
* See if it's a suppressed warning.
*/
@@ -1896,6 +2033,20 @@
((severity & ERR_PASS2) && pass0 != 2));
}
+/*
+ * Returns true if the given severity indicates a warning
+ * that is not suppressed and handled as error.
+ */
+bool nasm_is_warning_error(int severity)
+{
+ return ((severity & ERR_MASK) == ERR_WARNING
+ && !nasm_is_suppressed_warning(severity)
+ && (warning_error[(severity & ERR_WARN_MASK) >> ERR_WARN_SHR]
+ || warning_on[0]
+ )
+ );
+}
+
/**
* common error reporting
* This is the common back end of the error reporting schemes currently
--
You are receiving this mail because:
You are watching all bug changes.
You are on the CC list for the bug.
More information about the Nasm-bugs
mailing list