mirror of
https://github.com/netwide-assembler/nasm.git
synced 2024-11-27 08:10:07 +08:00
labels: Warn if new label created on pass two
When symbols are created turing non-first pass we should at least warn a user since it's a sign of potential problem. http://bugzilla.nasm.us/show_bug.cgi?id=3392358 Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
This commit is contained in:
parent
065c34273c
commit
5dfcab6bf9
27
labels.c
27
labels.c
@ -147,7 +147,7 @@ static void out_symdef(char *name, int32_t segment, int64_t offset,
|
||||
* given label name. Creates a new one, if it isn't found, and if
|
||||
* `create' is true.
|
||||
*/
|
||||
static union label *find_label(char *label, int create)
|
||||
static union label *find_label(char *label, int create, int *created)
|
||||
{
|
||||
char *prev;
|
||||
int prevlen, len;
|
||||
@ -175,8 +175,11 @@ static union label *find_label(char *label, int create)
|
||||
lpp = (union label **) hash_find(<ab, label, &ip);
|
||||
lptr = lpp ? *lpp : NULL;
|
||||
|
||||
if (lptr || !create)
|
||||
if (lptr || !create) {
|
||||
if (created)
|
||||
*created = 0;
|
||||
return lptr;
|
||||
}
|
||||
|
||||
/* Create a new label... */
|
||||
if (lfree->admin.movingon == END_BLOCK) {
|
||||
@ -188,6 +191,9 @@ static union label *find_label(char *label, int create)
|
||||
init_block(lfree);
|
||||
}
|
||||
|
||||
if (created)
|
||||
*created = 1;
|
||||
|
||||
lfree->admin.movingon = BOGUS_VALUE;
|
||||
lfree->defn.label = perm_copy(label);
|
||||
lfree->defn.special = NULL;
|
||||
@ -204,7 +210,7 @@ bool lookup_label(char *label, int32_t *segment, int64_t *offset)
|
||||
if (!initialized)
|
||||
return false;
|
||||
|
||||
lptr = find_label(label, 0);
|
||||
lptr = find_label(label, 0, NULL);
|
||||
if (lptr && (lptr->defn.is_global & DEFINED_BIT)) {
|
||||
*segment = lptr->defn.segment;
|
||||
*offset = lptr->defn.offset;
|
||||
@ -221,7 +227,7 @@ bool is_extern(char *label)
|
||||
if (!initialized)
|
||||
return false;
|
||||
|
||||
lptr = find_label(label, 0);
|
||||
lptr = find_label(label, 0, NULL);
|
||||
return (lptr && (lptr->defn.is_global & EXTERN_BIT));
|
||||
}
|
||||
|
||||
@ -229,7 +235,7 @@ void redefine_label(char *label, int32_t segment, int64_t offset, char *special,
|
||||
bool is_norm, bool isextrn)
|
||||
{
|
||||
union label *lptr;
|
||||
int exi;
|
||||
int exi, created;
|
||||
|
||||
/* This routine possibly ought to check for phase errors. Most assemblers
|
||||
* check for phase errors at this point. I don't know whether phase errors
|
||||
@ -248,10 +254,13 @@ void redefine_label(char *label, int32_t segment, int64_t offset, char *special,
|
||||
label, segment, offset, special, is_norm, isextrn);
|
||||
#endif
|
||||
|
||||
lptr = find_label(label, 1);
|
||||
lptr = find_label(label, 1, &created);
|
||||
if (!lptr)
|
||||
nasm_panic(0, "can't find label `%s' on pass two", label);
|
||||
|
||||
if (created)
|
||||
nasm_error(ERR_WARNING, "label `%s' defined on pass two", label);
|
||||
|
||||
if (!islocal(label)) {
|
||||
if (!islocalchar(*label) && lptr->defn.is_norm)
|
||||
prevlabel = lptr->defn.label;
|
||||
@ -301,7 +310,7 @@ void define_label(char *label, int32_t segment, int64_t offset, char *special,
|
||||
nasm_error(ERR_DEBUG, "define_label (%s, %"PRIx32", %"PRIx64", %s, %d, %d)",
|
||||
label, segment, offset, special, is_norm, isextrn);
|
||||
#endif
|
||||
lptr = find_label(label, 1);
|
||||
lptr = find_label(label, 1, NULL);
|
||||
if (!lptr)
|
||||
return;
|
||||
if (lptr->defn.is_global & DEFINED_BIT) {
|
||||
@ -353,7 +362,7 @@ void define_common(char *label, int32_t segment, int32_t size, char *special)
|
||||
{
|
||||
union label *lptr;
|
||||
|
||||
lptr = find_label(label, 1);
|
||||
lptr = find_label(label, 1, NULL);
|
||||
if (!lptr)
|
||||
return;
|
||||
if ((lptr->defn.is_global & DEFINED_BIT) &&
|
||||
@ -390,7 +399,7 @@ void declare_as_global(char *label, char *special)
|
||||
" global", label);
|
||||
return;
|
||||
}
|
||||
lptr = find_label(label, 1);
|
||||
lptr = find_label(label, 1, NULL);
|
||||
if (!lptr)
|
||||
return;
|
||||
switch (lptr->defn.is_global & TYPE_MASK) {
|
||||
|
Loading…
Reference in New Issue
Block a user