diff options
author | Cyrill Gorcunov <gorcunov@gmail.com> | 2016-07-27 01:08:51 +0300 |
---|---|---|
committer | Cyrill Gorcunov <gorcunov@gmail.com> | 2016-07-27 01:08:51 +0300 |
commit | 43bb293432306c41fa453d768fb21e4a98590f0a (patch) | |
tree | b0ff0420950e5f5220ff08046ab1ecbcab13725b /asm/labels.c | |
parent | bb0fa088fb1c05dfb68e93d2cfc5d28d5792da1d (diff) | |
parent | 1df89ea03902161b76773d0eef48f277b49d918e (diff) | |
download | nasm-43bb293432306c41fa453d768fb21e4a98590f0a.tar.gz |
Merge branch 'nasm-2.12.xx'
* nasm-2.12.xx:
codeview: Fix ill-formed "S_COMPILE2" record.
rdoff: Add rdf2bin input dependency
labels: Warn if new label created on pass two
Add explicit void parameter to newmembuf() function declaration.
compiler.h: always undefine __STRICT_ANSI__ for gcc
| Conflicts:
| rdoff/Makefile.in
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
Diffstat (limited to 'asm/labels.c')
-rw-r--r-- | asm/labels.c | 27 |
1 files changed, 18 insertions, 9 deletions
diff --git a/asm/labels.c b/asm/labels.c index a8df4780..224d6959 100644 --- a/asm/labels.c +++ b/asm/labels.c @@ -146,7 +146,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; @@ -174,8 +174,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) { @@ -187,6 +190,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; @@ -203,7 +209,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; @@ -220,7 +226,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)); } @@ -228,7 +234,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 @@ -247,10 +253,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; @@ -300,7 +309,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) { @@ -352,7 +361,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) && @@ -389,7 +398,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) { |