From 6df250aee3207b4cd7d9d11440de632e195c2398 Mon Sep 17 00:00:00 2001 From: "H. Peter Anvin" Date: Tue, 7 Oct 2025 08:30:02 -0700 Subject: [PATCH] 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) --- asm/parser.c | 6 ++++-- travis/test/aoutso.stderr | 2 +- travis/test/elfso-o0.stderr | 2 +- travis/test/elfso-ox.stderr | 2 +- travis/test/tmap.stderr | 2 +- 5 files changed, 8 insertions(+), 6 deletions(-) diff --git a/asm/parser.c b/asm/parser.c index a97a54d2e..219ce7a6c 100644 --- a/asm/parser.c +++ b/asm/parser.c @@ -746,6 +746,7 @@ restart_parse: if (i == TOKEN_ID || (insn_is_label && i == TOKEN_INSN)) { /* there's a label here */ + struct tokenval label = tokval; first = false; result->label = tokval.t_charptr; i = stdscan(NULL, &tokval); @@ -753,8 +754,9 @@ restart_parse: if (i == ':') { /* skip over the optional colon */ i = stdscan(NULL, &tokval); } else if (i == 0) { - nasm_warn(WARN_LABEL_ORPHAN , - "label alone on a line without a colon might be in error"); + nasm_warn(WARN_LABEL_ORPHAN, + "label `%*s' alone on a line without a colon might be in error", + (int)label.t_len, label.t_start); } if (i != TOKEN_INSN || tokval.t_integer != I_EQU) { /* diff --git a/travis/test/aoutso.stderr b/travis/test/aoutso.stderr index 165721843..7ec977eef 100644 --- a/travis/test/aoutso.stderr +++ b/travis/test/aoutso.stderr @@ -1 +1 @@ -./travis/test/aoutso.asm:79: warning: label alone on a line without a colon might be in error [-w+label-orphan] +./travis/test/aoutso.asm:79: warning: label `.end' alone on a line without a colon might be in error [-w+label-orphan] diff --git a/travis/test/elfso-o0.stderr b/travis/test/elfso-o0.stderr index 853ae39f7..15735cb0c 100644 --- a/travis/test/elfso-o0.stderr +++ b/travis/test/elfso-o0.stderr @@ -1 +1 @@ -./travis/test/elfso.asm:83: warning: label alone on a line without a colon might be in error [-w+label-orphan] +./travis/test/elfso.asm:83: warning: label `.end' alone on a line without a colon might be in error [-w+label-orphan] diff --git a/travis/test/elfso-ox.stderr b/travis/test/elfso-ox.stderr index 853ae39f7..15735cb0c 100644 --- a/travis/test/elfso-ox.stderr +++ b/travis/test/elfso-ox.stderr @@ -1 +1 @@ -./travis/test/elfso.asm:83: warning: label alone on a line without a colon might be in error [-w+label-orphan] +./travis/test/elfso.asm:83: warning: label `.end' alone on a line without a colon might be in error [-w+label-orphan] diff --git a/travis/test/tmap.stderr b/travis/test/tmap.stderr index c6505d038..666247770 100644 --- a/travis/test/tmap.stderr +++ b/travis/test/tmap.stderr @@ -1 +1 @@ -./travis/test/tmap.asm:938: warning: label alone on a line without a colon might be in error [-w+label-orphan] +./travis/test/tmap.asm:938: warning: label `.loop' alone on a line without a colon might be in error [-w+label-orphan]