0
0
mirror of https://github.com/netwide-assembler/nasm.git synced 2025-09-22 10:43:39 -04:00

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>
This commit is contained in:
Cyrill Gorcunov
2016-07-27 01:08:51 +03:00
3 changed files with 24 additions and 12 deletions

View File

@@ -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 * given label name. Creates a new one, if it isn't found, and if
* `create' is true. * `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; char *prev;
int prevlen, len; int prevlen, len;
@@ -174,8 +174,11 @@ static union label *find_label(char *label, int create)
lpp = (union label **) hash_find(&ltab, label, &ip); lpp = (union label **) hash_find(&ltab, label, &ip);
lptr = lpp ? *lpp : NULL; lptr = lpp ? *lpp : NULL;
if (lptr || !create) if (lptr || !create) {
if (created)
*created = 0;
return lptr; return lptr;
}
/* Create a new label... */ /* Create a new label... */
if (lfree->admin.movingon == END_BLOCK) { if (lfree->admin.movingon == END_BLOCK) {
@@ -187,6 +190,9 @@ static union label *find_label(char *label, int create)
init_block(lfree); init_block(lfree);
} }
if (created)
*created = 1;
lfree->admin.movingon = BOGUS_VALUE; lfree->admin.movingon = BOGUS_VALUE;
lfree->defn.label = perm_copy(label); lfree->defn.label = perm_copy(label);
lfree->defn.special = NULL; lfree->defn.special = NULL;
@@ -203,7 +209,7 @@ bool lookup_label(char *label, int32_t *segment, int64_t *offset)
if (!initialized) if (!initialized)
return false; return false;
lptr = find_label(label, 0); lptr = find_label(label, 0, NULL);
if (lptr && (lptr->defn.is_global & DEFINED_BIT)) { if (lptr && (lptr->defn.is_global & DEFINED_BIT)) {
*segment = lptr->defn.segment; *segment = lptr->defn.segment;
*offset = lptr->defn.offset; *offset = lptr->defn.offset;
@@ -220,7 +226,7 @@ bool is_extern(char *label)
if (!initialized) if (!initialized)
return false; return false;
lptr = find_label(label, 0); lptr = find_label(label, 0, NULL);
return (lptr && (lptr->defn.is_global & EXTERN_BIT)); 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) bool is_norm, bool isextrn)
{ {
union label *lptr; union label *lptr;
int exi; int exi, created;
/* This routine possibly ought to check for phase errors. Most assemblers /* 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 * 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); label, segment, offset, special, is_norm, isextrn);
#endif #endif
lptr = find_label(label, 1); lptr = find_label(label, 1, &created);
if (!lptr) if (!lptr)
nasm_panic(0, "can't find label `%s' on pass two", label); 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 (!islocal(label)) {
if (!islocalchar(*label) && lptr->defn.is_norm) if (!islocalchar(*label) && lptr->defn.is_norm)
prevlabel = lptr->defn.label; 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)", nasm_error(ERR_DEBUG, "define_label (%s, %"PRIx32", %"PRIx64", %s, %d, %d)",
label, segment, offset, special, is_norm, isextrn); label, segment, offset, special, is_norm, isextrn);
#endif #endif
lptr = find_label(label, 1); lptr = find_label(label, 1, NULL);
if (!lptr) if (!lptr)
return; return;
if (lptr->defn.is_global & DEFINED_BIT) { 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; union label *lptr;
lptr = find_label(label, 1); lptr = find_label(label, 1, NULL);
if (!lptr) if (!lptr)
return; return;
if ((lptr->defn.is_global & DEFINED_BIT) && if ((lptr->defn.is_global & DEFINED_BIT) &&
@@ -389,7 +398,7 @@ void declare_as_global(char *label, char *special)
" global", label); " global", label);
return; return;
} }
lptr = find_label(label, 1); lptr = find_label(label, 1, NULL);
if (!lptr) if (!lptr)
return; return;
switch (lptr->defn.is_global & TYPE_MASK) { switch (lptr->defn.is_global & TYPE_MASK) {

View File

@@ -43,8 +43,11 @@
#ifndef NASM_COMPILER_H #ifndef NASM_COMPILER_H
#define NASM_COMPILER_H 1 #define NASM_COMPILER_H 1
#ifdef __DJGPP__ /*
/* DJGPP has header file problems if __STRICT_ANSI__ is defined */ * At least DJGPP and Cygwin have broken header files if __STRICT_ANSI__
* is defined.
*/
#ifdef __GNUC__
# undef __STRICT_ANSI__ # undef __STRICT_ANSI__
#endif #endif

View File

@@ -68,7 +68,7 @@
* how int32_t it is). * how int32_t it is).
* ======================================================================== */ * ======================================================================== */
static memorybuffer *newmembuf() static memorybuffer *newmembuf(void)
{ {
memorybuffer *t; memorybuffer *t;