[qfcc] Print the source name of an undefined label

Undefined labels generated by the compiler indicate severe trouble.
This commit is contained in:
Bill Currie 2020-03-11 13:31:12 +09:00
parent 813319efc2
commit 393e540ffa
3 changed files with 10 additions and 4 deletions

View file

@ -75,6 +75,7 @@ typedef struct ex_label_s {
struct reloc_s *refs; ///< relocations associated with this label
struct sblock_s *dest; ///< the location of this label if known
const char *name; ///< the name of this label
struct symbol_s *symbol; ///< symbol used to define this label (maybe 0)
int used; ///< label is used as a target
struct daglabel_s *daglabel;
} ex_label_t;

View file

@ -499,6 +499,7 @@ expr_t *
named_label_expr (symbol_t *label)
{
symbol_t *sym;
expr_t *l;
if (!current_func) {
// XXX this might be only an error
@ -510,8 +511,11 @@ named_label_expr (symbol_t *label)
if (sym) {
return sym->s.expr;
}
l = new_label_expr ();
l->e.label.name = save_string (va ("%s_%s", l->e.label.name, label->name));
l->e.label.symbol = label;
label->sy_type = sy_expr;
label->s.expr = new_label_expr ();
label->s.expr = l;
symtab_addsymbol (current_func->label_scope, label);
return label->s.expr;
}

View file

@ -1590,9 +1590,10 @@ thread_jumps (sblock_t *blocks)
s = (statement_t *) sblock->tail;
if (statement_is_goto (s)) {
label = &s->opa->o.label;
if (!(*label)->dest && s->opa->expr) {
error (s->opa->expr, "undefined label `%s'", (*label)->name);
s->opa->expr = 0;
if (!(*label)->dest && (*label)->symbol) {
error (s->opa->expr, "undefined label `%s'",
(*label)->symbol->name);
(*label)->symbol = 0;
}
} else if (statement_is_cond (s)) {
label = &s->opb->o.label;