mirror of
https://github.com/netwide-assembler/nasm.git
synced 2025-03-19 18:00:23 +08:00
warnings: Make WARN_ constants consistent with -w options
Not only does this make it consistent, but allows for automation. Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
This commit is contained in:
parent
8e08fb6da7
commit
fef75c265a
@ -293,7 +293,7 @@ static const char *size_name(int size)
|
||||
|
||||
static void warn_overflow(int size)
|
||||
{
|
||||
nasm_warnf(ERR_PASS2 | WARN_NOV, "%s data exceeds bounds",
|
||||
nasm_warnf(ERR_PASS2 | WARN_NUMBER_OVERFLOW, "%s data exceeds bounds",
|
||||
size_name(size));
|
||||
}
|
||||
|
||||
@ -1674,7 +1674,7 @@ static void gencode(struct out_data *data, insn *ins)
|
||||
nasm_nonfatal("non-absolute expression not permitted "
|
||||
"as argument %d", c & 7);
|
||||
else if (opy->offset & ~mask)
|
||||
nasm_warnf(ERR_PASS2 | WARN_NOV,
|
||||
nasm_warnf(ERR_PASS2 | WARN_NUMBER_OVERFLOW,
|
||||
"is4 argument exceeds bounds");
|
||||
c = opy->offset & mask;
|
||||
goto emit_is4;
|
||||
@ -1696,7 +1696,7 @@ static void gencode(struct out_data *data, insn *ins)
|
||||
case4(0254):
|
||||
if (absolute_op(opx) &&
|
||||
(int32_t)opx->offset != (int64_t)opx->offset) {
|
||||
nasm_warnf(ERR_PASS2 | WARN_NOV,
|
||||
nasm_warnf(ERR_PASS2 | WARN_NUMBER_OVERFLOW,
|
||||
"signed dword immediate exceeds bounds");
|
||||
}
|
||||
out_imm(data, opx, 4, OUT_SIGNED);
|
||||
@ -1766,7 +1766,7 @@ static void gencode(struct out_data *data, insn *ins)
|
||||
/* If this wasn't explicitly byte-sized, warn as though we
|
||||
* had fallen through to the imm16/32/64 case.
|
||||
*/
|
||||
nasm_warnf(ERR_PASS2 | WARN_NOV,
|
||||
nasm_warnf(ERR_PASS2 | WARN_NUMBER_OVERFLOW,
|
||||
"%s value exceeds bounds",
|
||||
(opx->type & BITS8) ? "signed byte" :
|
||||
s == 16 ? "word" :
|
||||
|
10
asm/float.c
10
asm/float.c
@ -232,7 +232,7 @@ static bool ieee_flconvert(const char *string, fp_limb *mant,
|
||||
*p++ = *string - '0';
|
||||
} else {
|
||||
if (!warned) {
|
||||
nasm_warnf(WARN_FL_TOOLONG|ERR_PASS2,
|
||||
nasm_warnf(WARN_FLOAT_TOOLONG|ERR_PASS2,
|
||||
"floating-point constant significand contains "
|
||||
"more than %i digits", MANT_DIGITS);
|
||||
warned = true;
|
||||
@ -799,7 +799,7 @@ static int to_float(const char *str, int s, uint8_t *result,
|
||||
type = FL_NORMAL;
|
||||
} else if (exponent > 0) {
|
||||
if (pass0 == 1)
|
||||
nasm_warnf(WARN_FL_OVERFLOW|ERR_PASS2,
|
||||
nasm_warnf(WARN_FLOAT_OVERFLOW|ERR_PASS2,
|
||||
"overflow in floating-point constant");
|
||||
type = FL_INFINITY;
|
||||
} else {
|
||||
@ -834,11 +834,11 @@ static int to_float(const char *str, int s, uint8_t *result,
|
||||
} else {
|
||||
if (daz || is_zero(mant)) {
|
||||
/* Flush denormals to zero */
|
||||
nasm_warnf(WARN_FL_UNDERFLOW|ERR_PASS2,
|
||||
nasm_warnf(WARN_FLOAT_UNDERFLOW|ERR_PASS2,
|
||||
"underflow in floating-point constant");
|
||||
goto zero;
|
||||
} else
|
||||
nasm_warnf(WARN_FL_DENORM|ERR_PASS2,
|
||||
nasm_warnf(WARN_FLOAT_DENORM|ERR_PASS2,
|
||||
"denormal floating-point constant");
|
||||
}
|
||||
break;
|
||||
@ -853,7 +853,7 @@ static int to_float(const char *str, int s, uint8_t *result,
|
||||
ieee_shr(mant, 1);
|
||||
exponent++;
|
||||
if (exponent >= (expmax << 1)-1) {
|
||||
nasm_warnf(WARN_FL_OVERFLOW|ERR_PASS2,
|
||||
nasm_warnf(WARN_FLOAT_OVERFLOW|ERR_PASS2,
|
||||
"overflow in floating-point constant");
|
||||
type = FL_INFINITY;
|
||||
goto overflow;
|
||||
|
@ -517,14 +517,14 @@ void define_label(const char *label, int32_t segment,
|
||||
src_set(saved_line, saved_fname);
|
||||
} else if (changed && pass0 > 1 && lptr->defn.type != LBL_SPECIAL) {
|
||||
/*
|
||||
* WARN_LABEL_LATE defaults to an error, as this should never actually happen.
|
||||
* WARN_LABEL_REDEF_LATE defaults to an error, as this should never actually happen.
|
||||
* Just in case this is a backwards compatibility problem, still make it a
|
||||
* warning so that the user can suppress or demote it.
|
||||
*
|
||||
* As a special case, LBL_SPECIAL symbols are allowed to be changed
|
||||
* even during the last pass.
|
||||
*/
|
||||
nasm_warnf(WARN_LABEL_LATE,
|
||||
nasm_warnf(WARN_LABEL_REDEF_LATE,
|
||||
"label `%s' %s during code generation",
|
||||
lptr->defn.label, created ? "defined" : "changed");
|
||||
}
|
||||
|
@ -463,7 +463,7 @@ restart_parse:
|
||||
if (i == ':') { /* skip over the optional colon */
|
||||
i = stdscan(NULL, &tokval);
|
||||
} else if (i == 0) {
|
||||
nasm_warnf(WARN_OL | ERR_PASS1,
|
||||
nasm_warnf(WARN_ORPHAN_LABELS | ERR_PASS1,
|
||||
"label alone on a line without a colon might be in error");
|
||||
}
|
||||
if (i != TOKEN_INSN || tokval.t_integer != I_EQU) {
|
||||
|
@ -2133,7 +2133,7 @@ static bool parse_mmacro_spec(Token *tline, MMacro *def, const char *directive)
|
||||
|
||||
if (def->defaults && def->ndefs > def->nparam_max - def->nparam_min &&
|
||||
!def->plus)
|
||||
nasm_warnf(ERR_PASS1|WARN_MDP, "too many default macro parameters in macro `%s'", def->name);
|
||||
nasm_warnf(ERR_PASS1|WARN_MACRO_DEFAULTS, "too many default macro parameters in macro `%s'", def->name);
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -2966,7 +2966,7 @@ issue_error:
|
||||
count, nasm_limit[LIMIT_REP]);
|
||||
count = 0;
|
||||
} else if (count < 0) {
|
||||
nasm_warnf(ERR_PASS2|WARN_NEG_REP,
|
||||
nasm_warnf(ERR_PASS2|WARN_NEGATIVE_REP,
|
||||
"negative `%%rep' count: %"PRId64, count);
|
||||
count = 0;
|
||||
} else {
|
||||
|
@ -104,15 +104,15 @@ static inline vefunc nasm_set_verror(vefunc ve)
|
||||
#define WARN_IDX(x) ((x) >> WARN_SHR)
|
||||
|
||||
#define WARN_MNP WARN( 1) /* macro-num-parameters warning */
|
||||
#define WARN_MSR WARN( 2) /* macro self-reference */
|
||||
#define WARN_MDP WARN( 3) /* macro default parameters check */
|
||||
#define WARN_OL WARN( 4) /* orphan label (no colon, and alone on line) */
|
||||
#define WARN_NOV WARN( 5) /* numeric overflow */
|
||||
#define WARN_GNUELF WARN( 6) /* using GNU ELF extensions */
|
||||
#define WARN_FL_OVERFLOW WARN( 7) /* FP overflow */
|
||||
#define WARN_FL_DENORM WARN( 8) /* FP denormal */
|
||||
#define WARN_FL_UNDERFLOW WARN( 9) /* FP underflow */
|
||||
#define WARN_FL_TOOLONG WARN(10) /* FP too many digits */
|
||||
#define WARN_MACRO_SELFREF WARN( 2) /* macro self-reference */
|
||||
#define WARN_MACRO_DEFAULTS WARN( 3) /* macro default parameters check */
|
||||
#define WARN_ORPHAN_LABELS WARN( 4) /* orphan label (no colon, and alone on line) */
|
||||
#define WARN_NUMBER_OVERFLOW WARN( 5) /* numeric overflow */
|
||||
#define WARN_GNU_ELF_EXTENSIONS WARN( 6) /* using GNU ELF extensions */
|
||||
#define WARN_FLOAT_OVERFLOW WARN( 7) /* FP overflow */
|
||||
#define WARN_FLOAT_DENORM WARN( 8) /* FP denormal */
|
||||
#define WARN_FLOAT_UNDERFLOW WARN( 9) /* FP underflow */
|
||||
#define WARN_FLOAT_TOOLONG WARN(10) /* FP too many digits */
|
||||
#define WARN_USER WARN(11) /* %warning directives */
|
||||
#define WARN_LOCK WARN(12) /* bad LOCK prefixes */
|
||||
#define WARN_HLE WARN(13) /* bad HLE prefixes */
|
||||
@ -121,12 +121,12 @@ static inline vefunc nasm_set_verror(vefunc ve)
|
||||
#define WARN_PTR WARN(16) /* not a NASM keyword */
|
||||
#define WARN_BAD_PRAGMA WARN(17) /* malformed pragma */
|
||||
#define WARN_UNKNOWN_PRAGMA WARN(18) /* unknown pragma */
|
||||
#define WARN_NOTMY_PRAGMA WARN(19) /* pragma inapplicable */
|
||||
#define WARN_NOT_MY_PRAGMA WARN(19) /* pragma inapplicable */
|
||||
#define WARN_UNK_WARNING WARN(20) /* unknown warning */
|
||||
#define WARN_NEG_REP WARN(21) /* negative repeat count */
|
||||
#define WARN_NEGATIVE_REP WARN(21) /* negative repeat count */
|
||||
#define WARN_PHASE WARN(22) /* phase error in pass 1 */
|
||||
#define WARN_LABEL_REDEF WARN(23) /* label redefined, but consistent */
|
||||
#define WARN_LABEL_LATE WARN(24) /* label (re)defined during code generation */
|
||||
#define WARN_LABEL_REDEF_LATE WARN(24) /* label (re)defined during code generation */
|
||||
|
||||
/* These two should come last */
|
||||
#define WARN_ALL (24+2) /* Do not use WARN() here */
|
||||
|
@ -164,7 +164,7 @@ int64_t readnum(const char *str, bool *error)
|
||||
}
|
||||
|
||||
if (warn)
|
||||
nasm_error(ERR_WARNING | ERR_PASS1 | WARN_NOV,
|
||||
nasm_error(ERR_WARNING | ERR_PASS1 | WARN_NUMBER_OVERFLOW,
|
||||
"numeric constant %s does not fit in 64 bits",
|
||||
str);
|
||||
|
||||
|
@ -919,7 +919,7 @@ static void elf32_out(int32_t segto, const void *data,
|
||||
}
|
||||
|
||||
if (gnu16) {
|
||||
nasm_warnf(WARN_GNUELF, "8- or 16-bit relocations "
|
||||
nasm_warnf(WARN_GNU_ELF_EXTENSIONS, "8- or 16-bit relocations "
|
||||
"in ELF32 is a GNU extension");
|
||||
} else if (asize != 4 && segment != NO_SEG) {
|
||||
nasm_nonfatal("Unsupported non-32-bit ELF relocation");
|
||||
@ -945,7 +945,7 @@ rel12adr:
|
||||
" segment base references");
|
||||
} else {
|
||||
if (wrt == NO_SEG) {
|
||||
nasm_warnf(WARN_GNUELF, "8- or 16-bit relocations "
|
||||
nasm_warnf(WARN_GNU_ELF_EXTENSIONS, "8- or 16-bit relocations "
|
||||
"in ELF is a GNU extension");
|
||||
elf_add_reloc(s, segment, 0, reltype);
|
||||
} else {
|
||||
|
Loading…
x
Reference in New Issue
Block a user