diff options
Diffstat (limited to 'asm')
-rw-r--r-- | asm/listing.c | 9 | ||||
-rw-r--r-- | asm/parser.c | 14 | ||||
-rwxr-xr-x | asm/pptok.pl | 6 | ||||
-rw-r--r-- | asm/preproc.c | 95 | ||||
-rw-r--r-- | asm/stdscan.c | 2 | ||||
-rwxr-xr-x | asm/tokhash.pl | 6 | ||||
-rwxr-xr-x | asm/warnings.pl | 13 |
7 files changed, 67 insertions, 78 deletions
diff --git a/asm/listing.c b/asm/listing.c index 9b101ff4..6d6f3606 100644 --- a/asm/listing.c +++ b/asm/listing.c @@ -1,6 +1,6 @@ /* ----------------------------------------------------------------------- * * - * Copyright 1996-2019 The NASM Authors - All Rights Reserved + * Copyright 1996-2020 The NASM Authors - All Rights Reserved * See the file AUTHORS included with the NASM distribution for * the specific copyright holders. * @@ -276,8 +276,13 @@ static void list_output(const struct out_data *data) break; case OUT_RESERVE: { - if (size) + if (size > 8) { list_size(offset, "res", size); + } else { + memset(q, '?', size << 1); + q[size << 1] = '\0'; + list_out(offset, q); + } break; } default: diff --git a/asm/parser.c b/asm/parser.c index de24103e..7c24cc00 100644 --- a/asm/parser.c +++ b/asm/parser.c @@ -1,6 +1,6 @@ /* ----------------------------------------------------------------------- * * - * Copyright 1996-2019 The NASM Authors - All Rights Reserved + * Copyright 1996-2020 The NASM Authors - All Rights Reserved * See the file AUTHORS included with the NASM distribution for * the specific copyright holders. * @@ -234,7 +234,8 @@ static bool parse_braces(decoflags_t *decoflags) } } -static inline const expr *next_expr(const expr *e, const expr **next_list) +static inline unused +const expr *next_expr(const expr *e, const expr **next_list) { e++; if (!e->type) { @@ -830,7 +831,14 @@ restart_parse: /* DB et al */ result->operands = oper_num; if (oper_num == 0) - nasm_warn(WARN_OTHER, "no operand for data declaration"); + /*! + *!db-empty [on] no operand for data declaration + *! warns about a \c{DB}, \c{DW}, etc declaration + *! with no operands, producing no output. + *! This is permitted, but often indicative of an error. + *! See \k{db}. + */ + nasm_warn(WARN_DB_EMPTY, "no operand for data declaration"); } return result; } diff --git a/asm/pptok.pl b/asm/pptok.pl index a4853f2e..5498cb46 100755 --- a/asm/pptok.pl +++ b/asm/pptok.pl @@ -223,19 +223,19 @@ if ($what eq 'c') { # Put a large value in unused slots. This makes it extremely unlikely # that any combination that involves unused slot will pass the range test. # This speeds up rejection of unrecognized tokens, i.e. identifiers. - print OUT "#define UNUSED (65535/3)\n"; + print OUT "#define UNUSED_HASH_ENTRY (65535/3)\n"; print OUT " static const int16_t hash1[$n] = {\n"; for ($i = 0; $i < $n; $i++) { my $h = ${$g}[$i*2+0]; - print OUT " ", defined($h) ? $h : 'UNUSED', ",\n"; + print OUT " ", defined($h) ? $h : 'UNUSED_HASH_ENTRY', ",\n"; } print OUT " };\n"; print OUT " static const int16_t hash2[$n] = {\n"; for ($i = 0; $i < $n; $i++) { my $h = ${$g}[$i*2+1]; - print OUT " ", defined($h) ? $h : 'UNUSED', ",\n"; + print OUT " ", defined($h) ? $h : 'UNUSED_HASH_ENTRY', ",\n"; } print OUT " };\n"; diff --git a/asm/preproc.c b/asm/preproc.c index 0a6e2451..eee4d8a9 100644 --- a/asm/preproc.c +++ b/asm/preproc.c @@ -345,7 +345,8 @@ static inline bool tok_text_match(const struct Token *a, const struct Token *b) return a->len == b->len && !memcmp(tok_text(a), tok_text(b), a->len); } -static inline bool tok_match(const struct Token *a, const struct Token *b) +static inline unused bool +tok_match(const struct Token *a, const struct Token *b) { return a->type == b->type && tok_text_match(a, b); } @@ -763,7 +764,8 @@ static const char *unquote_token_cstr(Token *t) * TOK_STRING tokens. */ static Token *quote_any_token(Token *t); -static inline Token *quote_token(Token *t) +static inline unused +Token *quote_token(Token *t) { if (likely(!tok_is(t, TOK_INTERNAL_STRING))) return t; @@ -4886,17 +4888,15 @@ static int mmac_rotate(const MMacro *mac, unsigned int n) /* * expands to a list of tokens from %{x:y} */ -static Token *expand_mmac_params_range(MMacro *mac, Token *tline, Token ***last) +void expand_mmac_params_range(MMacro *mac, Token *tline, Token ***tail) { - Token *t = tline, **tt, *tm, *head; - char *pos; - int fst, lst, j, i; - - pos = strchr(tok_text(tline), ':'); - nasm_assert(pos); + Token *t; + const char *arg = tok_text(tline) + 1; + int fst, lst, incr, n; + int parsed; - lst = atoi(pos + 1); - fst = atoi(tok_text(tline) + 1); + parsed = sscanf(arg, "%d:%d", &fst, &lst); + nasm_assert(parsed == 2); /* * only macros params are accounted so @@ -4914,56 +4914,28 @@ static Token *expand_mmac_params_range(MMacro *mac, Token *tline, Token ***last) fst = fst < 0 ? fst + (int)mac->nparam + 1: fst; lst = lst < 0 ? lst + (int)mac->nparam + 1: lst; - /* count from zero */ - fst--, lst--; - /* - * It will be at least one token. Note we - * need to scan params until separator, otherwise - * only first token will be passed. + * It will be at least one parameter, as we can loop + * in either direction. */ - j = (fst + mac->rotate) % mac->nparam; - tm = mac->params[j+1]; - if (!tm) - goto err; - head = dup_Token(NULL, tm); - tt = &head->next, tm = tm->next; - while (tok_isnt(tm, ',')) { - t = dup_Token(NULL, tm); - *tt = t, tt = &t->next, tm = tm->next; - } + incr = (fst < lst) ? 1 : -1; - if (fst < lst) { - for (i = fst + 1; i <= lst; i++) { - t = make_tok_char(NULL, ','); - *tt = t, tt = &t->next; - j = (i + mac->rotate) % mac->nparam; - tm = mac->params[j+1]; - while (tok_isnt(tm, ',')) { - t = dup_Token(NULL, tm); - *tt = t, tt = &t->next, tm = tm->next; - } - } - } else { - for (i = fst - 1; i >= lst; i--) { - t = make_tok_char(NULL, ','); - *tt = t, tt = &t->next; - j = (i + mac->rotate) % mac->nparam; - tm = mac->params[j+1]; - while (!tok_isnt(tm, ',')) { - t = dup_Token(NULL, tm); - *tt = t, tt = &t->next, tm = tm->next; - } - } + while (true) { + n = mmac_rotate(mac, fst); + dup_tlistn(mac->params[n], mac->paramlen[n], tail); + if (fst == lst) + break; + t = make_tok_char(NULL, ','); + **tail = t; + *tail = &t->next; + fst += incr; } - *last = tt; - return head; + return; err: - nasm_nonfatal("`%%{%s}': macro parameters out of range", - tok_text(tline) + 1); - return NULL; + nasm_nonfatal("`%%{%s}': macro parameters out of range", arg); + return; } /* @@ -5014,16 +4986,9 @@ static Token *expand_mmac_params(Token * tline) } if (strchr(text, ':')) { - /* - * seems we have a parameters range here - */ - Token *head, **last; - head = expand_mmac_params_range(mac, t, &last); - if (head) { - *tail = head; - *last = tline; - text = NULL; - } + /* It is a range */ + expand_mmac_params_range(mac, t, &tail); + text = NULL; break; } @@ -5999,7 +5964,7 @@ static MMacro *is_mmacro(Token * tline, int *nparamp, Token ***paramsp) *! The legacy behavior is quite strange and highly context-dependent, *! and can be disabled with: *!- - *! \c %pragma preproc sane_empty_expansion true + *! \c %pragma preproc sane_empty_expansion true *!- *! It is highly recommended to use this option in new code. */ diff --git a/asm/stdscan.c b/asm/stdscan.c index c1c38f42..cbc0fc77 100644 --- a/asm/stdscan.c +++ b/asm/stdscan.c @@ -164,7 +164,7 @@ int stdscan(void *private_data, struct tokenval *tv) *!ptr [on] non-NASM keyword used in other assemblers *! warns about keywords used in other assemblers that might *! indicate a mistake in the source code. Currently only the MASM - *! \c{PTR} keyword is recognized. + *! \c{PTR} keyword is recognized. See also \k{pkg_masm}. */ nasm_warn(WARN_PTR, "`%s' is not a NASM keyword", tv->t_charptr); diff --git a/asm/tokhash.pl b/asm/tokhash.pl index 9dbe77a2..9303157b 100755 --- a/asm/tokhash.pl +++ b/asm/tokhash.pl @@ -234,19 +234,19 @@ if ($output eq 'h') { # Put a large value in unused slots. This makes it extremely unlikely # that any combination that involves unused slot will pass the range test. # This speeds up rejection of unrecognized tokens, i.e. identifiers. - print "#define UNUSED (65535/3)\n"; + print "#define UNUSED_HASH_ENTRY (65535/3)\n"; print " static const int16_t hash1[$n] = {\n"; for ($i = 0; $i < $n; $i++) { my $h = ${$g}[$i*2+0]; - print " ", defined($h) ? $h : 'UNUSED', ",\n"; + print " ", defined($h) ? $h : 'UNUSED_HASH_ENTRY', ",\n"; } print " };\n"; print " static const int16_t hash2[$n] = {\n"; for ($i = 0; $i < $n; $i++) { my $h = ${$g}[$i*2+1]; - print " ", defined($h) ? $h : 'UNUSED', ",\n"; + print " ", defined($h) ? $h : 'UNUSED_HASH_ENTRY', ",\n"; } print " };\n"; diff --git a/asm/warnings.pl b/asm/warnings.pl index a609e132..8a79568a 100755 --- a/asm/warnings.pl +++ b/asm/warnings.pl @@ -253,7 +253,18 @@ if ($what eq 'c') { } else { my $docdef = $whatdef{$warn->{def}}; - @doc = @{$warn->{doc}}; + my $newpara = 0; + foreach my $l (@{$warn->{doc}}) { + if ($l =~ /^\s*$/) { + $newpara = 1; + } else { + if ($newpara && $l !~ /^\\c\s+/) { + $l = '\> ' . $l; + } + $newpara = 0; + } + push(@doc, $l); + } if (defined($docdef)) { push(@doc, "\n", "\\> $docdef by default.\n"); } |