Skip to content

Commit 6df250a

Browse files
author
H. Peter Anvin
committed
parser: add the actual name of a label to the label-orphan warning
The label-orphan warning is *way* more useful if it includes the actual label name; this way the programmer can usually spot immediately if it is a label or misspelled instruction. Signed-off-by: H. Peter Anvin (Intel) <[email protected]>
1 parent d66187c commit 6df250a

File tree

5 files changed

+8
-6
lines changed

5 files changed

+8
-6
lines changed

asm/parser.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -746,15 +746,17 @@ insn *parse_line(char *buffer, insn *result, const int bits)
746746

747747
if (i == TOKEN_ID || (insn_is_label && i == TOKEN_INSN)) {
748748
/* there's a label here */
749+
struct tokenval label = tokval;
749750
first = false;
750751
result->label = tokval.t_charptr;
751752
i = stdscan(NULL, &tokval);
752753
colonless_label = i != ':';
753754
if (i == ':') { /* skip over the optional colon */
754755
i = stdscan(NULL, &tokval);
755756
} else if (i == 0) {
756-
nasm_warn(WARN_LABEL_ORPHAN ,
757-
"label alone on a line without a colon might be in error");
757+
nasm_warn(WARN_LABEL_ORPHAN,
758+
"label `%*s' alone on a line without a colon might be in error",
759+
(int)label.t_len, label.t_start);
758760
}
759761
if (i != TOKEN_INSN || tokval.t_integer != I_EQU) {
760762
/*

travis/test/aoutso.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
./travis/test/aoutso.asm:79: warning: label alone on a line without a colon might be in error [-w+label-orphan]
1+
./travis/test/aoutso.asm:79: warning: label `.end' alone on a line without a colon might be in error [-w+label-orphan]

travis/test/elfso-o0.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
./travis/test/elfso.asm:83: warning: label alone on a line without a colon might be in error [-w+label-orphan]
1+
./travis/test/elfso.asm:83: warning: label `.end' alone on a line without a colon might be in error [-w+label-orphan]

travis/test/elfso-ox.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
./travis/test/elfso.asm:83: warning: label alone on a line without a colon might be in error [-w+label-orphan]
1+
./travis/test/elfso.asm:83: warning: label `.end' alone on a line without a colon might be in error [-w+label-orphan]

travis/test/tmap.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
./travis/test/tmap.asm:938: warning: label alone on a line without a colon might be in error [-w+label-orphan]
1+
./travis/test/tmap.asm:938: warning: label `.loop' alone on a line without a colon might be in error [-w+label-orphan]

0 commit comments

Comments
 (0)