[Nasm-bugs] [Bug 3392632] New: [Feature request] [Patch] Add label-no-colon warning
noreply-nasm at dev.nasm.us
noreply-nasm at dev.nasm.us
Fri Nov 22 04:38:12 PST 2019
https://bugzilla.nasm.us/show_bug.cgi?id=3392632
Bug ID: 3392632
Summary: [Feature request] [Patch] Add label-no-colon warning
Product: NASM
Version: 2.15 (development)
Hardware: All
OS: All
Status: OPEN
Severity: enhancement
Priority: Medium
Component: Assembler
Assignee: nobody at nasm.us
Reporter: pushbx at ulukai.org
CC: chang.seok.bae at intel.com, gorcunov at gmail.com,
hpa at zytor.com, nasm-bugs at nasm.us
Obtained from: Built from git using configure
I went into my old local fork of NASM and lifted the label-no-colon warning
from it. However, I changed it to the simpler implementation for now.
> This is a simplistic approach which will result in duplicate warnings
> if both label-no-colon and label-orphan are enabled. A more advanced
> approach would require functions such as nasm_is_suppressed_warning
> and nasm_is_warning_error, to figure out which warning to emit and
> whether the warning should be an error or not.
First referenced in: https://sourceforge.net/p/nasm/mailman/message/36494605/
[Nasm-devel] Question for a patch: How to handle a warning class that is a
superset of another warning class?
Patches uploaded to github at
https://github.com/ecm-pushbx/nasm/commits/ecm-2019-11
Intended behaviour as shown with a simple test case:
$ cat test.asm
label_colon_empty: ; line 1
label_nocolon_empty ; line 2
label_colon_inst: nop ; line 3
label_nocolon_inst nop ; line 4
label_colon_equ: equ 1 ; line 5
label_nocolon_equ equ 1 ; line 6
; line 7
nop ; line 8
$ nasm test.asm
test.asm:2: warning: label `label_nocolon_empty' alone on a line without a
colon might be in error [-w+label-orphan]
$ nasm test.asm -w+label
test.asm:2: warning: label `label_nocolon_empty' alone on a line without a
colon might be in error [-w+label-orphan]
test.asm:2: warning: label `label_nocolon_empty' not followed by a colon
[-w+label-no-colon]
test.asm:4: warning: label `label_nocolon_inst' not followed by a colon
[-w+label-no-colon]
$ nasm test.asm -w+label -w-label-orphan
test.asm:2: warning: label `label_nocolon_empty' not followed by a colon
[-w+label-no-colon]
test.asm:4: warning: label `label_nocolon_inst' not followed by a colon
[-w+label-no-colon]
$
This is the patch itself, in case you don't want to or cannot use github:
$ git diff -r ab19..HEAD
diff --git a/asm/parser.c b/asm/parser.c
index a59acb19..6f1802a6 100644
--- a/asm/parser.c
+++ b/asm/parser.c
@@ -678,7 +678,7 @@ restart_parse:
i = stdscan(NULL, &tokval);
if (i == ':') { /* skip over the optional colon */
i = stdscan(NULL, &tokval);
- } else if (i == 0) {
+ } else if (i != TOKEN_INSN || tokval.t_integer != I_EQU) {
/*!
*!label-orphan [on] labels alone on lines without trailing `:'
*!=orphan-labels
@@ -686,8 +686,19 @@ restart_parse:
*! a label without a trailing colon. This is most likely
indicative
*! of a typo, but is technically correct NASM syntax (see
\k{syntax}.)
*/
- nasm_warn(WARN_LABEL_ORPHAN ,
- "label alone on a line without a colon might be in
error");
+ if (i == 0) {
+ nasm_warn(WARN_LABEL_ORPHAN,
+ "label `%s' alone on a line without a colon might
be in error",
+ result->label);
+ }
+ /*!
+ *!label-no-colon [off] labels without trailing `:'
+ *! warns about source lines which define a label that
+ *! is specified without a trailing colon and without an EQU.
+ */
+ nasm_warn(WARN_LABEL_NO_COLON,
+ "label `%s' not followed by a colon",
+ result->label);
}
if (i != TOKEN_INSN || tokval.t_integer != I_EQU) {
/*
--
You are receiving this mail because:
You are on the CC list for the bug.
You are watching all bug changes.
More information about the Nasm-bugs
mailing list