diff --git a/Makefile.in b/Makefile.in index f3fba9db..c34ff4a6 100644 --- a/Makefile.in +++ b/Makefile.in @@ -416,37 +416,19 @@ editors: $(EDITORS) WARNTIMES = $(WARNFILES:=.time) .PHONY: warnings -warnings: - $(RM_F) $(WARNFILES) $(WARNTIMES) asm/warnings.time - $(MAKE) asm/warnings.time +warnings: $(WARNFILES) -asm/warnings.time: $(WARNSRCS) asm/warnings.pl - $(EMPTY) asm/warnings.time - $(MAKE) $(WARNTIMES) - -asm/warnings_c.h.time: asm/warnings.pl asm/warnings.time +asm/warnings_c.h: asm/warnings.pl asm/warnings.dat $(RUNPERL) $(srcdir)/asm/warnings.pl c asm/warnings_c.h \ - $(srcdir) $(WARNSRCS) - $(EMPTY) asm/warnings_c.h.time + $(srcdir)/asm/warnings.dat -asm/warnings_c.h: asm/warnings_c.h.time - $(SIDE) - -include/warnings.h.time: asm/warnings.pl asm/warnings.time +include/warnings.h: asm/warnings.pl asm/warnings.dat $(RUNPERL) $(srcdir)/asm/warnings.pl h include/warnings.h \ - $(srcdir) $(WARNSRCS) - $(EMPTY) include/warnings.h.time + $(srcdir)/asm/warnings.dat -include/warnings.h: include/warnings.h.time - $(SIDE) - -doc/warnings.src.time: asm/warnings.pl asm/warnings.time +doc/warnings.src: asm/warnings.pl asm/warnings.dat $(RUNPERL) $(srcdir)/asm/warnings.pl doc doc/warnings.src \ - $(srcdir) $(WARNSRCS) - $(EMPTY) doc/warnings.src.time - -doc/warnings.src : doc/warnings.src.time - $(SIDE) + $(srcdir)/asm/warnings.dat $(PERLREQ): $(DIRS) diff --git a/asm/assemble.c b/asm/assemble.c index 661dd3fe..39567e82 100644 --- a/asm/assemble.c +++ b/asm/assemble.c @@ -249,17 +249,6 @@ static void debug_macro_out(const struct out_data *data) * generator at the same time, flatten unnecessary relocations, * and verify backend compatibility. */ -/* - * This warning is currently issued by backends, but in the future - * this code should be centralized. - * - *!zeroing [on] \c{RES}\e{x} in initialized section becomes zero - *! a \c{RES}\e{x} directive was used in a section which contains - *! initialized data, and the output format does not support - *! this. Instead, this will be replaced with explicit zero - *! content, which may produce a large output file. - */ - /* * Add the entries in struct out_data for the rather bizarre legacy * backend interface, and then submit to the backend. @@ -400,78 +389,6 @@ static void out(struct out_data *data) asize = amax = 0; /* No longer an address */ } } else { - /*! - *!reloc-abs-byte [off] 8-bit absolute section-crossing relocation - *! warns that an 8-bit absolute relocation that could - *! not be resolved at assembly time was generated in - *! the output format. - *! - *! This is usually normal, but may not be handled by all - *! possible target environments - */ - /*! - *!reloc-abs-word [off] 16-bit absolute section-crossing relocation - *! warns that a 16-bit absolute relocation that could - *! not be resolved at assembly time was generated in - *! the output format. - *! - *! This is usually normal, but may not be handled by all - *! possible target environments - */ - /*! - *!reloc-abs-dword [off] 32-bit absolute section-crossing relocation - *! warns that a 32-bit absolute relocation that could - *! not be resolved at assembly time was generated in - *! the output format. - *! - *! This is usually normal, but may not be handled by all - *! possible target environments - */ - /*! - *!reloc-abs-qword [off] 64-bit absolute section-crossing relocation - *! warns that a 64-bit absolute relocation that could - *! not be resolved at assembly time was generated in - *! the output format. - *! - *! This is usually normal, but may not be handled by all - *! possible target environments - */ - /*! - *!reloc-rel-byte [off] 8-bit relative section-crossing relocation - *! warns that an 8-bit relative relocation that could - *! not be resolved at assembly time was generated in - *! the output format. - *! - *! This is usually normal, but may not be handled by all - *! possible target environments - */ - /*! - *!reloc-rel-word [off] 16-bit relative section-crossing relocation - *! warns that a 16-bit relative relocation that could - *! not be resolved at assembly time was generated in - *! the output format. - *! - *! This is usually normal, but may not be handled by all - *! possible target environments - */ - /*! - *!reloc-rel-dword [off] 32-bit relative section-crossing relocation - *! warns that a 32-bit relative relocation that could - *! not be resolved at assembly time was generated in - *! the output format. - *! - *! This is usually normal, but may not be handled by all - *! possible target environments - */ - /*! - *!reloc-rel-qword [off] 64-bit relative section-crossing relocation - *! warns that an 64-bit relative relocation that could - *! not be resolved at assembly time was generated in - *! the output format. - *! - *! This is usually normal, but may not be handled by all - *! possible target environments - */ int warn; const char *type; @@ -538,11 +455,6 @@ static void out(struct out_data *data) nasm_nonfatal("%u-bit signed relocation unsupported by output format %s", (unsigned int)(asize << 3), ofmt->shortname); } else { - /*! - *!zext-reloc [on] relocation zero-extended to match output format - *! warns that a relocation has been zero-extended due - *! to limitations in the output format. - */ nasm_warn(WARN_ZEXT_RELOC, "%u-bit %s relocation zero-extended from %u bits", (unsigned int)(asize << 3), @@ -1050,27 +962,9 @@ static int64_t assemble(insn *instruction) * warning classes for "obsolete but valid for this * specific CPU" and "obsolete and gone." * - *!obsolete-removed [on] instruction obsolete and removed on the target CPU - *! warns for an instruction which has been removed - *! from the architecture, and is no longer included - *! in the CPU definition given in the \c{[CPU]} - *! directive, for example \c{POP CS}, the opcode for - *! which, \c{0Fh}, instead is an opcode prefix on - *! CPUs newer than the first generation 8086. - * - *!obsolete-nop [on] instruction obsolete and is a noop on the target CPU - *! warns for an instruction which has been removed - *! from the architecture, but has been architecturally - *! defined to be a noop for future CPUs. - * - *!obsolete-valid [on] instruction obsolete but valid on the target CPU - *! warns for an instruction which has been removed - *! from the architecture, but is still valid on the - *! specific CPU given in the \c{CPU} directive. Code - *! using these instructions is most likely not - *! forward compatible. + * This currently doesn't really happen correctly; + * it requires better information in insns.dat. */ - whathappened = never ? "never implemented" : "obsolete"; if (!never && !iflag_cmp_cpu_level(&insns_flags[temp->iflag_idx], &cpu)) { @@ -1417,12 +1311,6 @@ static void bad_hle_warn(const insn * ins, uint8_t hleok) if (!is_class(MEMORY, ins->oprs[0].type)) ww = w_inval; /* HLE requires operand 0 to be memory */ - /*! - *!prefix-hle [on] invalid HLE prefix - *!=hle - *! warns about invalid use of the HLE \c{XACQUIRE} or \c{XRELEASE} - *! prefixes. - */ switch (ww) { case w_none: break; @@ -1723,11 +1611,6 @@ static int64_t calcsize(insn *ins, const struct itemplate * const temp) case 0320: is_o16: { - /*!prefix-opsize [on] invalid operand size prefix - *! warns that an operand prefix (\c{o16}, \c{o32}, \c{o64}, - *! \c{osp}) invalid for the specified instruction has been specified. - *! The operand prefix will be ignored by the assembler. - */ enum prefixes pfx = ins->prefixes[PPS_OSIZE]; ins->op_size = 16; if (bits != 16 && pfx == P_OSP) { @@ -1861,17 +1744,6 @@ static int64_t calcsize(insn *ins, const struct itemplate * const temp) break; case 0340: - /*! - *!forward [on] forward reference may have unpredictable results - *! warns that a forward reference is used which may have - *! unpredictable results, notably in a \c{RESB}-type - *! pseudo-instruction. These would be \i\e{critical - *! expressions} (see \k{crit}) but are permitted in a - *! handful of cases for compatibility with older - *! versions of NASM. This warning should be treated as a - *! severe programming error as the code could break at - *! any time for any number of reasons. - */ /* The bytecode ends in 0, so opx points to operand 0 */ if (!absolute_op(opx)) { nasm_nonfatal("attempt to reserve non-constant" @@ -1960,16 +1832,6 @@ static int64_t calcsize(insn *ins, const struct itemplate * const temp) if (ins->prefixes[PPS_REP] == P_BND) { /* jmp short (opcode eb) cannot be used with bnd prefix. */ ins->prefixes[PPS_REP] = P_none; - /*! - *!prefix-bnd [on] invalid \c{BND} prefix - *!=bnd - *! warns about ineffective use of the \c{BND} prefix when the - *! \c{JMP} instruction is converted to the \c{SHORT} form. - *! This should be extremely rare since the short \c{JMP} only - *! is applicable to jumps inside the same module, but if - *! it is legitimate, it may be necessary to use - *! \c{bnd jmp dword}. - */ if (!ins->dummy) nasm_warn(WARN_PREFIX_BND, "jmp short does not init bnd regs - bnd prefix dropped"); @@ -2196,21 +2058,8 @@ static int64_t calcsize(insn *ins, const struct itemplate * const temp) if (lockcheck && has_prefix(ins, PPS_LOCK, P_LOCK)) { if ((!itemp_has(temp,IF_LOCK) || !is_class(MEMORY, ins->oprs[0].type)) && (!itemp_has(temp,IF_LOCK1) || !is_class(MEMORY, ins->oprs[1].type))) { - /*! - *!prefix-lock-error [on] \c{LOCK} prefix on unlockable instruction - *!=lock - *! warns about \c{LOCK} prefixes on unlockable instructions. - */ nasm_warn(WARN_PREFIX_LOCK_ERROR, "instruction is not lockable"); } else if (temp->opcode == I_XCHG) { - /*! - *!prefix-lock-xchg [on] superfluous \c{LOCK} prefix on \c{XCHG} instruction - *! warns about a \c{LOCK} prefix added to an \c{XCHG} instruction. - *! The \c{XCHG} instruction is \e{always} locking, and so this - *! prefix is not necessary; however, NASM will generate it if - *! explicitly provided by the user, so this warning indicates that - *! suboptimal code is being generated. - */ nasm_warn(WARN_PREFIX_LOCK_XCHG, "superfluous LOCK prefix on XCHG instruction"); } @@ -2232,17 +2081,6 @@ static int64_t calcsize(insn *ins, const struct itemplate * const temp) */ if (ins->prefixes[PPS_SEG] == P_PT || ins->prefixes[PPS_SEG] == P_PN) { if (!itemp_has(temp, IF_JCC_HINT)) { - /*! - *!prefix-hint-dropped [on] invalid branch hint prefix dropped - *! warns that the \c{{PT}} (predict taken) or \c{{PN}} - *! (predict not taken) branch prediction hint prefixes - *! are specified on an instruction that does not take - *! these prefixes. As these prefixes alias the segment - *! override prefixes, this may be a very serious error, - *! and therefore NASM will not generate these prefixes. - *! To force these prefixes to be emitted, use \c{DS} or - *! \c{CS}, instead, respectively. - */ nasm_warn(WARN_PREFIX_HINT_DROPPED, "invalid branch hint prefix dropped"); ins->prefixes[PPS_SEG] = 0; @@ -2428,13 +2266,6 @@ static int emit_prefixes(struct out_data *data, const insn *ins) c = r; break; default: - /*! - *!prefix-invalid [on] invalid prefix for instruction - *! this instruction is only valid with certain combinations - *! of prefixes. The prefix will still be generated as - *! requested, but the result may be a completely different - *! instruction. - */ if (do_warn) nasm_warn(WARN_PREFIX_INVALID, "invalid prefix %s for instruction, result may be unexpected", @@ -2453,12 +2284,6 @@ static int emit_prefixes(struct out_data *data, const insn *ins) /* fall through */ case R_ES: case R_SS: - /*! - *!prefix-seg [on] segment prefix ignored in 64-bit mode - *! warns that an \c{es}, \c{cs}, \c{ss} or \c{ds} segment override - *! prefix has no effect in 64-bit mode. The prefix will still be - *! generated as requested. - */ if (do_warn && bits == 64) { nasm_warn(WARN_PREFIX_SEG, "%s segment override will be ignored in 64-bit mode", @@ -3620,12 +3445,6 @@ static int process_ea(operand *input, int rfield, opflags_t rflags, input->type |= IP_REL; } if ((input->type & IP_REL) == IP_REL) { - /*! - *!ea-absolute [on] absolute address cannot be RIP-relative - *! warns that an address that is inherently absolute cannot - *! be generated with RIP-relative encoding using \c{REL}, - *! see \k{default-rel}. - */ if (input->segment == NO_SEG || (input->opflags & OPFLAG_RELATIVE)) { nasm_warn(WARN_EA_ABSOLUTE, @@ -3644,12 +3463,6 @@ static int process_ea(operand *input, int rfield, opflags_t rflags, if ((eaflags & EAF_BYTEOFFS) || ((eaflags & EAF_WORDOFFS) && input->disp_size != (addrbits != 16 ? 32 : 16))) { - /*! - *!ea-dispsize [on] displacement size ignored on absolute address - *! warns that NASM does not support generating displacements for - *! inherently absolute addresses that do not match the address size - *! of the instruction. - */ nasm_warn(WARN_EA_DISPSIZE, "displacement size ignored on absolute address"); } diff --git a/asm/error.c b/asm/error.c index efae72cb..a9671bc8 100644 --- a/asm/error.c +++ b/asm/error.c @@ -128,12 +128,6 @@ void pop_warnings(void) memcpy(warning_state, ws->state, sizeof warning_state); if (!ws->next) { - /*! - *!warn-stack-empty [on] warning stack empty - *! a \c{[WARNING POP]} directive was executed when - *! the warning stack is empty. This is treated - *! as a \c{[WARNING *all]} directive. - */ nasm_warn(WARN_WARN_STACK_EMPTY, "warning stack empty"); } else { warning_stack = ws->next; @@ -168,15 +162,9 @@ void reset_warnings(void) * This is called when processing a -w or -W option, or a warning directive. * Returns ok if the action was successful. * - * Special pseudo-warnings: - * - *!other [on] any warning not specifically mentioned above - *! specifies any warning not included in any specific warning class. - * - *!all [all] all possible warnings - *! is an group alias for \e{all} warning classes. Thus, \c{-w+all} - *! enables all available warnings, and \c{-w-all} disables warnings - *! entirely (since NASM 2.13). + * Special pseudo-warnings (see warnings.dat): + * all - all possible warnings + * other - any warning not specifically assigned a class */ bool set_warning_status(const char *value) { @@ -277,11 +265,6 @@ bool set_warning_status(const char *value) } if (!ok && value) { - /*! - *!unknown-warning [off] unknown warning in \c{-W}/\c{-w} or warning directive - *! warns about a \c{-w} or \c{-W} option or a \c{[WARNING]} directive - *! that contains an unknown warning name or is otherwise not possible to process. - */ nasm_warn(WARN_UNKNOWN_WARNING, "unknown warning name: %s", value); } diff --git a/asm/floats.c b/asm/floats.c index 7dced050..beff3d4a 100644 --- a/asm/floats.c +++ b/asm/floats.c @@ -199,10 +199,6 @@ static bool ieee_flconvert(const char *string, fp_limb *mant, *p++ = *string - '0'; } else { if (!warned) { - /*! - *!float-toolong [on] too many digits in floating-point number - *! warns about too many digits in floating-point numbers. - */ nasm_warn(WARN_FLOAT_TOOLONG|ERR_PASS2, "floating-point constant significand contains " "more than %i digits", MANT_DIGITS); @@ -803,19 +799,10 @@ int float_const(const char *str, int s, uint8_t *result, enum floatize ffmt) mant[0] |= exponent << (LIMB_BITS-1 - fmt->exponent); } else { if (daz || is_zero(mant)) { - /*! - *!float-underflow [off] floating point underflow - *! warns about floating point underflow (a nonzero - *! constant rounded to zero.) - */ nasm_warn(WARN_FLOAT_UNDERFLOW|ERR_PASS2, "underflow in floating-point constant"); goto zero; } else { - /*! - *!float-denorm [off] floating point denormal - *! warns about denormal floating point constants. - */ nasm_warn(WARN_FLOAT_DENORM|ERR_PASS2, "denormal floating-point constant"); } @@ -832,10 +819,6 @@ int float_const(const char *str, int s, uint8_t *result, enum floatize ffmt) ieee_shr(mant, 1); exponent++; if (exponent >= (expmax << 1)-1) { - /*! - *!float-overflow [on] floating point overflow - *! warns about floating point underflow. - */ nasm_warn(WARN_FLOAT_OVERFLOW|ERR_PASS2, "overflow in floating-point constant"); type = FL_INFINITY; diff --git a/asm/labels.c b/asm/labels.c index 22481b3c..d8ac8f6f 100644 --- a/asm/labels.c +++ b/asm/labels.c @@ -495,12 +495,6 @@ void define_label(const char *label, int32_t segment, nasm_nonfatal("label `%s' inconsistently redefined", lptr->defn.label); noteflags = ERR_NONFATAL|ERR_HERE|ERR_NO_SEVERITY; } else { - /*! - *!label-redef [off] label redefined to an identical value - *! warns if a label is defined more than once, but the - *! value is identical. It is an unconditional error to - *! define the same label more than once to \e{different} values. - */ nasm_warn(WARN_LABEL_REDEF, "info: label `%s' redefined to an identical value", lptr->defn.label); noteflags = ERR_WARNING|ERR_HERE|ERR_NO_SEVERITY|WARN_LABEL_REDEF; @@ -511,19 +505,7 @@ void define_label(const char *label, int32_t segment, nasm_error(noteflags, "info: label `%s' originally defined", lptr->defn.label); src_set(saved_line, saved_fname); } else if (changed && pass_final() && lptr->defn.type != LBL_SPECIAL) { - /*! - *!label-redef-late [err] label (re)defined during code generation - *! the value of a label changed during the final, code-generation - *! pass. This may be the result of strange use of the - *! preprocessor. This is very likely to produce incorrect code and - *! may end up being an unconditional error in a future - *! version of NASM. - * - * WARN_LABEL_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. - * + /* * Note: As a special case, LBL_SPECIAL symbols are allowed * to be changed even during the last pass. */ diff --git a/asm/nasm.c b/asm/nasm.c index 6d492569..635ad92a 100644 --- a/asm/nasm.c +++ b/asm/nasm.c @@ -1730,12 +1730,6 @@ static void assemble_file(const char *fname, struct strlist *depend_list) break; case PASS_STAB: - /*! - *!phase [off] phase error during stabilization - *! warns about symbols having changed values during - *! the second-to-last assembly pass. This is not - *! inherently fatal, but may be a source of bugs. - */ nasm_warn(WARN_PHASE|ERR_UNDEAD, "phase error during stabilization " "pass, hoping for the best"); diff --git a/asm/parser.c b/asm/parser.c index 4193e3d5..dddbdf51 100644 --- a/asm/parser.c +++ b/asm/parser.c @@ -300,14 +300,6 @@ static void mref_set_optype(operand *op) flag = IP_REL; if (!(globl.reldef & op->eaflags)) { static int64_t pass_last_seen; - /*! - *!implicit-abs-deprecated [on] implicit DEFAULT ABS is deprecated - *! - *! warns that in a subsequent version of NASM, the 64-bit default - *! addressing form is likely to change from \c{DEFAULT ABS} to - *! \c{DEFAULT REL}. If absolute addressing is indeed intended, it is - *! strongly recommended to specify \c{DEFAULT ABS} explicitly. - */ if (pass_count() != pass_last_seen) { nasm_warn(WARN_IMPLICIT_ABS_DEPRECATED, "implicit DEFAULT ABS is deprecated"); @@ -761,13 +753,6 @@ restart_parse: if (i == ':') { /* skip over the optional colon */ i = stdscan(NULL, &tokval); } else if (i == 0) { - /*! - *!label-orphan [on] labels alone on lines without trailing \c{:} - *!=orphan-labels - *! warns about source lines which contain no instruction but define - *! a label without a trailing colon. This is most likely indicative - *! of a typo, but is technically correct NASM syntax (see \k{syntax}.) - */ nasm_warn(WARN_LABEL_ORPHAN , "label alone on a line without a colon might be in error"); } @@ -909,13 +894,6 @@ restart_parse: /* DB et al */ result->operands = oper_num; if (oper_num == 0) - /*! - *!db-empty [on] no operand for data declaration - *! warns about a \c{D}\e{x} 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; @@ -1397,21 +1375,6 @@ restart_parse: if (!opsize) { op->type |= rs; /* For non-size-specific registers, permit size override */ } else if (opsize != rs) { - /*! - *!regsize [on] register size specification ignored - *! - *! warns about a register with implicit size (such as \c{EAX}, which is always 32 bits) - *! been given an explicit size specification which is inconsistent with the size - *! of the named register, e.g. \c{WORD EAX}. \c{DWORD EAX} or \c{WORD AX} are - *! permitted, and do not trigger this warning. Some registers which \e{do not} imply - *! a specific size, such as \c{K0}, may need this specification unless the instruction - *! itself implies the instruction size: - *!- - *! \c KMOVW K0,[foo] ; Permitted, KMOVW implies 16 bits - *! \c KMOV WORD K0,[foo] ; Permitted, WORD K0 specifies instruction size - *! \c KMOV K0,WORD [foo] ; Permitted, WORD [foo] specifies instruction size - *! \c KMOV K0,[foo] ; Not permitted, instruction size ambiguous - */ nasm_warn(WARN_REGSIZE, "invalid register size specification ignored"); } } diff --git a/asm/pragma.c b/asm/pragma.c index b5ae699d..ce3e8149 100644 --- a/asm/pragma.c +++ b/asm/pragma.c @@ -162,22 +162,10 @@ found_it: case DIRR_UNKNOWN: switch (pragma.opcode) { case D_none: - /*! - *!pragma-bad [off] malformed \c{%pragma} - *!=bad-pragma - *! warns about a malformed or otherwise unparsable - *! \c{%pragma} directive. - */ nasm_warn(ERR_PASS2|WARN_PRAGMA_BAD, "empty %%pragma %s", pragma.facility_name); break; default: - /*! - *!pragma-unknown [off] unknown \c{%pragma} facility or directive - *!=unknown-pragma - *! warns about an unknown \c{%pragma} directive. - *! This is not yet implemented for most cases. - */ nasm_warn(ERR_PASS2|WARN_PRAGMA_UNKNOWN, "unknown %%pragma %s %s", pragma.facility_name, pragma.opname); @@ -205,21 +193,7 @@ found_it: return rv; } -/* This warning message is intended for future use */ -/*! - *!pragma-na [off] \c{%pragma} not applicable to this compilation - *!=not-my-pragma - *! warns about a \c{%pragma} directive which is not applicable to - *! this particular assembly session. This is not yet implemented. - */ - /* Naked %pragma */ -/*! - *!pragma-empty [off] empty \c{%pragma} directive - *! warns about a \c{%pragma} directive containing nothing. - *! This is treated identically to \c{%pragma ignore} except - *! for this optional warning. - */ void process_pragma(char *str) { const struct pragma_facility *pf; diff --git a/asm/preproc.c b/asm/preproc.c index d4077a2f..ba2b89d9 100644 --- a/asm/preproc.c +++ b/asm/preproc.c @@ -935,17 +935,6 @@ static const char *pp_getenv(const Token *t, bool warn) v = getenv(txt); if (warn && !v) { - /*! - *!pp-environment [on] nonexistent environment variable - *!=environment - *! warns if a nonexistent environment variable - *! is accessed using the \c{%!} preprocessor - *! construct (see \k{getenv}.) Such environment - *! variables are treated as empty (with this - *! warning issued) starting in NASM 2.15; - *! earlier versions of NASM would treat this as - *! an error. - */ nasm_warn(WARN_PP_ENVIRONMENT, "nonexistent environment variable `%s'", txt); v = ""; @@ -1560,17 +1549,6 @@ static Token *tokenize(const char *line) * nasm_skip_string() */ if (!*p) { - /*! - *!pp-open-brackets [on] unterminated \c{%[...]} - *! warns that a preprocessor \c{%[...]} construct - *! lacks the terminating \c{]} character. - */ - /*! - *!pp-open-braces [on] unterminated \c{%\{...\}} - *! warns that a preprocessor parameter - *! enclosed in braces \c{%\{...\}} lacks the - *! terminating \c{\}} character. - */ nasm_warn(firstchar == '}' ? WARN_PP_OPEN_BRACES : WARN_PP_OPEN_BRACKETS, "unterminated %%%c...%c construct (missing `%c')", @@ -1630,12 +1608,6 @@ static Token *tokenize(const char *line) if (toklen < 2) { type = '%'; /* % operator */ if (unlikely(*line == '{')) { - /*! - *!pp-empty-braces [on] empty \c{%\{\}} construct - *! warns that an empty \c{%\{\}} was encountered. - *! This expands to a single \c{%} character, which - *! is normally the \c{%} arithmetic operator. - */ nasm_warn(WARN_PP_EMPTY_BRACES, "empty %%{} construct expands to the %% operator"); } @@ -1741,11 +1713,6 @@ static Token *tokenize(const char *line) if (*p) { p++; } else { - /*! - *!pp-open-string [on] unterminated string - *! warns that a quoted string without a closing quotation - *! mark was encountered during preprocessing. - */ nasm_warn(WARN_PP_OPEN_STRING, "unterminated string (missing `%c')", quote); type = TOKEN_ERRSTR; @@ -2372,13 +2339,6 @@ static bool pp_get_boolean_option(Token *tline, bool defval) return true; if (tokval.t_type) { - /*! - *!pp-trailing [on] trailing garbage ignored - *! warns that the preprocessor encountered additional text - *! where no such text was expected. This can - *! sometimes be the result of an incorrectly written expression, - *! or arguments that are inadvertently separated. - */ nasm_warn(WARN_PP_TRAILING, "trailing garbage after expression ignored"); } @@ -3609,17 +3569,6 @@ static SMacro *define_smacro(const char *mname, bool casesense, if (casesense ^ smac->casesense) { /* - *!pp-macro-def-case-single [on] single-line macro defined both case sensitive and insensitive - *!=macro-def-case-single - *! warns when a single-line macro is defined both case - *! sensitive and case insensitive. - *! The new macro - *! definition will override (shadow) the original one, - *! although the original macro is not deleted, and will - *! be re-exposed if the new macro is deleted with - *! \c{%undef}, or, if the original macro is the case - *! insensitive one, the macro call is done with a - *! different case. */ nasm_warn(WARN_PP_MACRO_DEF_CASE_SINGLE, "case %ssensitive definition of macro `%s' will shadow %ssensitive macro `%s'", casesense ? "" : "in", @@ -3629,36 +3578,15 @@ static SMacro *define_smacro(const char *mname, bool casesense, defined = false; } else if ((!!nparam) ^ (!!smac->nparam)) { /* - * Most recent versions of NASM considered this an error, - * so promote this warning to error by default. - * - *!pp-macro-def-param-single [err] single-line macro defined with and without parameters - *!=macro-def-param-single - *! warns if the same single-line macro is defined with and - *! without parameters. - *! The new macro - *! definition will override (shadow) the original one, - *! although the original macro is not deleted, and will - *! be re-exposed if the new macro is deleted with - *! \c{%undef}. + * The immediately previous versions of NASM considered + * this an error, so promote this warning is promoted to + * to error by default. */ nasm_warn(WARN_PP_MACRO_DEF_PARAM_SINGLE, "macro `%s' defined both with and without parameters", mname); defined = false; } else if (smac->nparam < nparam) { - /* - *!pp-macro-def-greedy-single [on] single-line macro - *!=macro-def-greedy-single - *! definition shadows greedy macro warns when a - *! single-line macro is defined which would match a - *! previously existing greedy definition. The new macro - *! definition will override (shadow) the original one, - *! although the original macro is not deleted, and will - *! be re-exposed if the new macro is deleted with - *! \c{%undef}, and will be invoked if called with a - *! parameter count that does not match the new definition. - */ nasm_warn(WARN_PP_MACRO_DEF_GREEDY_SINGLE, "defining macro `%s' shadows previous greedy definition", mname); @@ -3847,12 +3775,6 @@ 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) { - /* - *!pp-macro-defaults [on] macros with more default than optional parameters - *!=macro-defaults - *! warns when a macro has more default parameters than optional parameters. - *! See \k{mlmacdef} for why might want to disable this warning. - */ nasm_warn(WARN_PP_MACRO_DEFAULTS, "too many default macro parameters in macro `%s'", def->name); } @@ -4326,10 +4248,6 @@ static void user_error(enum preproc_token op, Token **tlinep) severity = ERR_NOTE; break; case PP_WARNING: - /*! - *!user [on] \c{%warning} directives - *! controls output of \c{%warning} directives (see \k{pperror}). - */ severity = ERR_WARNING|WARN_USER|ERR_PASS2; break; case PP_ERROR: @@ -4933,12 +4851,6 @@ static int do_directive(Token *tline, Token **output, bool suppressed) case COND_ELSE_TRUE: case COND_ELSE_FALSE: - /*! - *!pp-else-elif [on] \c{%elif} after \c{%else} - *! warns that an \c{%elif}-type directive was encountered - *! after \c{%else} has already been encounted. As a result, the - *! content of the \c{%elif} will never be expanded. - */ nasm_warn(WARN_PP_ELSE_ELIF|ERR_PP_PRECOND, "`%s' after `%%else', ignoring content", dname); istk->conds->state = COND_NEVER; @@ -4983,12 +4895,6 @@ static int do_directive(Token *tline, Token **output, bool suppressed) case COND_ELSE_TRUE: case COND_ELSE_FALSE: - /*! - *!pp-else-else [on] \c{%else} after \c{%else} - *! warns that a second \c{%else} clause was found for - *! the same \c{%if} statement. The content of this \c{%else} - *! clause will never be expanded. - */ nasm_warn(WARN_PP_ELSE_ELSE|ERR_PP_PRECOND, "`%s' after `%%else', ignoring content", dname); istk->conds->state = COND_NEVER; @@ -5046,12 +4952,6 @@ static int do_directive(Token *tline, Token **output, bool suppressed) || defining->plus) && (defining->nparam_min <= mmac->nparam_max || mmac->plus)) { - /*! - *!pp-macro-redef-multi [on] redefining multi-line macro - *! warns that a multi-line macro is being redefined, - *! without first removing the old definition with - *! \c{%unmacro}. - */ nasm_warn(WARN_PP_MACRO_REDEF_MULTI, "redefining multi-line macro `%s'", defining->name); @@ -5199,12 +5099,6 @@ static int do_directive(Token *tline, Token **output, bool suppressed) dname, count, nasm_limit[LIMIT_REP]); count = 0; } else if (count < 0) { - /*! - *!pp-rep-negative [on] regative \c{%rep} count - *!=negative-rep - *! warns about a negative count given to the \c{%rep} - *! preprocessor directive. - */ nasm_warn(ERR_PASS2|WARN_PP_REP_NEGATIVE, "negative `%s' count: %"PRId64, dname, count); count = 0; @@ -6546,12 +6440,6 @@ static SMacro *expand_one_smacro(Token ***tpp) */ while (1) { if (!m) { - /*! - *!pp-macro-params-single [on] single-line macro calls with wrong parameter count - *!=macro-params-single - *! warns about \i{single-line macros} being invoked - *! with the wrong number of parameters. - */ nasm_warn(WARN_PP_MACRO_PARAMS_SINGLE|ERR_HOLD, "single-line macro `%s' exists, " "but not taking %d parameter%s", @@ -6942,22 +6830,6 @@ static MMacro *is_mmacro(Token * tline, int *nparamp, Token ***paramsp) * To disable these insane legacy behaviors, use: * * %pragma preproc sane_empty_expansion yes - * - *!pp-macro-params-legacy [on] improperly calling multi-line macro for legacy support - *!=macro-params-legacy - *! warns about \i{multi-line macros} being invoked - *! with the wrong number of parameters, but for bug-compatibility - *! with NASM versions older than 2.15, NASM tried to fix up the - *! parameters to match the legacy behavior and call the macro anyway. - *! This can happen in certain cases where there are empty arguments - *! without braces, sometimes as a result of macro expansion. - *!- - *! The legacy behavior is quite strange and highly context-dependent, - *! and can be disabled with: - *!- - *! \c %pragma preproc sane_empty_expansion true - *!- - *! It is highly recommended to use this option in new code. */ if (!ppconf.sane_empty_expansion) { if (!found) { @@ -7022,12 +6894,6 @@ static MMacro *is_mmacro(Token * tline, int *nparamp, Token ***paramsp) /* * After all that, we didn't find one with the right number of * parameters. Issue a warning, and fail to expand the macro. - *! - *!pp-macro-params-multi [on] multi-line macro calls with wrong parameter count - *!=macro-params-multi - *! warns about \i{multi-line macros} being invoked - *! with the wrong number of parameters. See \k{mlmacover} for an - *! example of why you might want to disable this warning. */ if (found) return found; @@ -7880,12 +7746,6 @@ stdmac_cond_sel(const SMacro *s, Token **params, int nparams) return NULL; } } else { - /*! - *!pp-sel-range [on] \c{%sel()} argument out of range - *! warns that the \c{%sel()} preprocessor function was passed - *! a value less than 1 or larger than the number of available - *! arguments. - */ if (unlikely(which < 1)) { nasm_warn(WARN_PP_SEL_RANGE, "%s(%"PRId64") is not a valid selector", s->name, which); diff --git a/asm/stdscan.c b/asm/stdscan.c index 77d311f0..6903b0ce 100644 --- a/asm/stdscan.c +++ b/asm/stdscan.c @@ -318,15 +318,6 @@ static int stdscan_token(struct tokenval *tv) int token_type = nasm_token_hash(tv->t_charptr, tv); if (unlikely(tv->t_flag & TFLAG_WARN)) { - /*!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. If (limited) MASM compatibility is - *! desired, the \c{%use masm} macro package is - *! available, see \k{pkg_masm}; however, carefully note - *! the caveats listed. - */ nasm_warn(WARN_PTR, "`%s' is not a NASM keyword", tv->t_charptr); } diff --git a/asm/warnings.dat b/asm/warnings.dat new file mode 100644 index 00000000..4485aa30 --- /dev/null +++ b/asm/warnings.dat @@ -0,0 +1,425 @@ +all [group] all possible warnings + \c{all} is an group alias for \e{all} warning classes. Thus, \c{-w+all} + enables all available warnings, and \c{-w-all} disables warnings + entirely (since NASM 2.13). + +db-empty [on] no operand for data declaration + Warns about a \c{D}\e{x} declaration + with no operands, producing no output. + This is permitted, but often indicative of an error. + See \k{db}. + +ea-absolute [on] absolute address cannot be RIP-relative + Warns that an address that is inherently absolute cannot + be generated with RIP-relative encoding using \c{REL}, + see \k{default-rel}. + +ea-dispsize [on] displacement size ignored on absolute address + Warns that NASM does not support generating displacements for + inherently absolute addresses that do not match the address size + of the instruction. + +float-denorm [off] floating point denormal + Warns about denormal floating point constants. + +float-overflow [on] floating point overflow + Warns about floating point underflow. + +float-toolong [on] too many digits in floating-point number + Warns about too many digits in floating-point numbers. + +float-underflow [off] floating point underflow + Warns about floating point underflow (a nonzero + constant rounded to zero.) + +forward [on] forward reference may have unpredictable results + Warns that a forward reference is used which may have + unpredictable results, notably in a \c{RESB}-type + pseudo-instruction. These would be \i\e{critical + expressions} (see \k{crit}) but are permitted in a + handful of cases for compatibility with older + versions of NASM. This warning should be treated as a + severe programming error as the code could break at + any time for any number of reasons. + +implicit-abs-deprecated [on] implicit DEFAULT ABS is deprecated + Warns that in a future version of NASM, the 64-bit default + addressing form is likely to change from \c{DEFAULT ABS} to + \c{DEFAULT REL}. If absolute addressing is indeed intended, it is + strongly recommended to specify \c{DEFAULT ABS} explicitly. + +label-orphan [on] labels alone on lines without trailing \c{:} +=orphan-labels + Warns about source lines which contain no instruction but define + a label without a trailing colon. This is most likely indicative + of a typo, but is technically correct NASM syntax (see \k{syntax}.) + +label-redef [off] label redefined to an identical value + Warns if a label is defined more than once, but the + value is identical. It is an unconditional error to + define the same label more than once to \e{different} values. + +# +# 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. +# +label-redef-late [err] label (re)defined during code generation + The value of a label changed during the final, code-generation + pass. This may be the result of strange use of the + preprocessor. This is very likely to produce incorrect code and + may end up being an unconditional error in a future + version of NASM. + +number-deprecated-hex [on] $ prefix for hexadecimal is deprecated + Warns that the \c{$} prefix for hexadecimal numbers is + deprecated, due to the syntactic conflict with \c{$} used + as a symbol escape prefix. This syntax may be disabled by + default in a future version of NASM. Replace \c{$} with \c{0x} + to ensure compatibility with future versions. + +number-overflow [on] numeric constant does not fit + Covers warnings about numeric constants which + don't fit in 64 bits. + +obsolete-nop [on] instruction obsolete and is a noop on the target CPU + Warns for an instruction which has been removed + from the architecture, but has been architecturally + defined to be a noop for future CPUs. + +obsolete-removed [on] instruction obsolete and removed on the target CPU + Warns for an instruction which has been removed + from the architecture, and is no longer included + in the CPU definition given in the \c{[CPU]} + directive, for example \c{POP CS}, the opcode for + which, \c{0Fh}, instead is an opcode prefix on + CPUs newer than the first generation 8086. + +obsolete-valid [on] instruction obsolete but valid on the target CPU + Warns for an instruction which has been removed + from the architecture, but is still valid on the + specific CPU given in the \c{CPU} directive. Code + using these instructions is most likely not + forward compatible. + +other [on] any warning not assigned to a specific warning class + Specifies any warning not included in any specific warning class. + +phase [off] phase error during stabilization + Warns about symbols having changed values during + the second-to-last assembly pass. This is not + inherently fatal, but may be a source of bugs. + +pp-else-elif [on] \c{%elif} after \c{%else} + Warns that an \c{%elif}-type directive was encountered + after \c{%else} has already been encounted. As a result, the + content of the \c{%elif} will never be expanded. + +pp-else-else [on] \c{%else} after \c{%else} + Warns that a second \c{%else} clause was found for + the same \c{%if} statement. The content of this \c{%else} + clause will never be expanded. + +pp-empty-braces [on] empty \c{%\{\}} construct + Warns that an empty \c{%\{\}} was encountered. + This expands to a single \c{%} character, which + is normally the \c{%} arithmetic operator. + +pp-environment [on] nonexistent environment variable +=environment + Warns if a nonexistent environment variable + is accessed using the \c{%!} preprocessor + construct (see \k{getenv}.) Such environment + variables are treated as empty (with this + warning issued) starting in NASM 2.15; + earlier versions of NASM would treat this as + an error. + +pp-macro-def-case-single [on] single-line macro defined both case sensitive and insensitive +=macro-def-case-single + Warns when a single-line macro is defined both case + sensitive and case insensitive. + The new macro + definition will override (shadow) the original one, + although the original macro is not deleted, and will + be re-exposed if the new macro is deleted with + \c{%undef}, or, if the original macro is the case + insensitive one, the macro call is done with a + different case. + +pp-macro-def-greedy-single [on] single-line macro +=macro-def-greedy-single + Warns that a single-line macro is defined which would match a + previously existing greedy definition. The new macro definition + will override (shadow) the original one, although the original + macro is not deleted, and will be re-exposed if the new macro is + deleted with \c{%undef}, and will be invoked if called with a + parameter count that does not match the new definition. + +# The immediately previous versions of NASM considered +# this an error, so promote this warning is promoted to +# to error by default. +pp-macro-def-param-single [err] single-line macro defined with and without parameters +=macro-def-param-single + Warns if the same single-line macro is defined with and without + parameters. The new macro definition will override (shadow) the + original one, although the original macro is not deleted, and will + be re-exposed if the new macro is deleted with \c{%undef}. + +pp-macro-defaults [on] macros with more default than optional parameters +=macro-defaults + Warns when a macro has more default parameters than optional parameters. + See \k{mlmacdef} for why one might want to disable this warning. + +pp-macro-params-legacy [on] improperly calling multi-line macro for legacy support +=macro-params-legacy + Warns about \i{multi-line macros} being invoked + with the wrong number of parameters, but for bug-compatibility + with NASM versions older than 2.15, NASM tried to fix up the + parameters to match the legacy behavior and call the macro anyway. + This can happen in certain cases where there are empty arguments + without braces, sometimes as a result of macro expansion. + + The legacy behavior is quite strange and highly context-dependent, + and can be disabled with: + + \c %pragma preproc sane_empty_expansion true + + It is highly recommended to use this option in new code. + +pp-macro-params-multi [on] multi-line macro calls with wrong parameter count +=macro-params-multi + Warns about \i{multi-line macros} being invoked + with the wrong number of parameters. See \k{mlmacover} for an + example of why you might want to disable this warning. + +pp-macro-params-single [on] single-line macro calls with wrong parameter count +=macro-params-single + Warns about \i{single-line macros} being invoked + with the wrong number of parameters. + +pp-macro-redef-multi [on] redefining multi-line macro + Warns that a multi-line macro is being redefined, + without first removing the old definition with + \c{%unmacro}. + +pp-open-braces [on] unterminated \c{%\{...\}} + Warns that a preprocessor parameter + enclosed in braces \c{%\{...\}} lacks the + terminating \c{\}} character. + +pp-open-brackets [on] unterminated \c{%[...]} + Warns that a preprocessor \c{%[...]} construct + lacks the terminating \c{]} character. + +pp-open-string [on] unterminated string + Warns that a quoted string without a closing quotation + mark was encountered during preprocessing. + +pp-rep-negative [on] regative \c{%rep} count +=negative-rep + Warns about a negative count given to the \c{%rep} + preprocessor directive. + +pp-sel-range [on] \c{%sel()} argument out of range + Warns that the \c{%sel()} preprocessor function was passed + a value less than 1 or larger than the number of available + arguments. + +pp-trailing [on] trailing garbage ignored + Warns that the preprocessor encountered additional text + where no such text was expected. This can + sometimes be the result of an incorrectly written expression, + or arguments that are inadvertently separated. + +pragma-bad [off] malformed \c{%pragma} +=bad-pragma + Warns about a malformed or otherwise unparsable + \c{%pragma} directive. + +pragma-empty [off] empty \c{%pragma} directive + Warns about a \c{%pragma} directive containing nothing. + This is treated identically to \c{%pragma ignore} except + for this optional warning. + +# Not implemented yet +pragma-na [off] \c{%pragma} not applicable to this compilation +=not-my-pragma + Warns about a \c{%pragma} directive which is not applicable to + this particular assembly session. This is not yet implemented. + +pragma-unknown [off] unknown \c{%pragma} facility or directive +=unknown-pragma + Warns about an unknown \c{%pragma} directive. + This is not yet implemented for most cases. + +prefix-bnd [on] invalid \c{BND} prefix +=bnd + Warns about ineffective use of the \c{BND} prefix when the + \c{JMP} instruction is converted to the \c{SHORT} form. + This should be extremely rare since the short \c{JMP} only + is applicable to jumps inside the same module, but if + it is legitimate, it may be necessary to use + \c{bnd jmp dword}. + +prefix-hint-dropped [on] invalid branch hint prefix dropped + Warns that the \c{{PT}} (predict taken) or \c{{PN}} + (predict not taken) branch prediction hint prefixes + are specified on an instruction that does not take + these prefixes. As these prefixes alias the segment + override prefixes, this may be a very serious error, + and therefore NASM will not generate these prefixes. + To force these prefixes to be emitted, use \c{DS} or + \c{CS}, instead, respectively. + +prefix-hle [on] invalid HLE prefix +=hle + Warns about invalid use of the HLE \c{XACQUIRE} or \c{XRELEASE} + prefixes. + +prefix-invalid [on] invalid prefix for instruction + Warns about an instruction which is only valid with certain + combinations of prefixes. The prefix will still be generated as + requested, but the result may be a completely different + instruction or result in a \c{#UD} trap. + +prefix-lock-error [on] \c{LOCK} prefix on unlockable instruction +=lock + Warns about \c{LOCK} prefixes specified on unlockable instructions. + +prefix-lock-xchg [on] superfluous \c{LOCK} prefix on \c{XCHG} instruction + Warns about a \c{LOCK} prefix added to an \c{XCHG} instruction. + The \c{XCHG} instruction is \e{always} locking, and so this + prefix is not necessary; however, NASM will generate it if + explicitly provided by the user, so this warning indicates that + suboptimal code is being generated. + +prefix-opsize [on] invalid operand size prefix + Warns that an operand prefix (\c{o16}, \c{o32}, \c{o64}, + \c{osp}) invalid for the specified instruction has been specified. + The operand prefix will be ignored by the assembler. + +prefix-seg [on] segment prefix ignored in 64-bit mode + Warns that an \c{es}, \c{cs}, \c{ss} or \c{ds} segment override + prefix has no effect in 64-bit mode. The prefix will still be + generated as requested. + +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. If (limited) MASM compatibility is + desired, the \c{%use masm} macro package is + available, see \k{pkg_masm}; however, carefully note + the caveats listed. + +regsize [on] register size specification ignored + Warns about a register with implicit size (such as \c{EAX}, which + is always 32 bits) been given an explicit size specification which + is inconsistent with the size of the named register, e.g. \c{WORD + EAX}. \c{DWORD EAX} or \c{WORD AX} are permitted, and do not + trigger this warning. Some registers which \e{do not} imply a + specific size, such as \c{K0}, may need this specification unless + the instruction itself implies the instruction size: + + \c KMOVW K0,[foo] ; OK: KMOVW = 16 bits + \c KMOV WORD K0,[foo] ; OK: WORD K0 = 16 bits + \c KMOV K0,WORD [foo] ; OK: WORD [foo] = 16 bits + \c KMOV K0,[foo] ; Error: unknown size + +reloc-abs-byte [off] 8-bit absolute section-crossing relocation + Warns that an 8-bit absolute relocation that could + not be resolved at assembly time was generated in + the output format. + + This is usually normal, but may not be handled by all + possible target environments + +reloc-abs-dword [off] 32-bit absolute section-crossing relocation + Warns that a 32-bit absolute relocation that could + not be resolved at assembly time was generated in + the output format. + + This is usually normal, but may not be handled by all + possible target environments + +reloc-abs-qword [off] 64-bit absolute section-crossing relocation + Warns that a 64-bit absolute relocation that could + not be resolved at assembly time was generated in + the output format. + + This is usually normal, but may not be handled by all + possible target environments + +reloc-abs-word [off] 16-bit absolute section-crossing relocation + Warns that a 16-bit absolute relocation that could + not be resolved at assembly time was generated in + the output format. + + This is usually normal, but may not be handled by all + possible target environments + +reloc-rel-byte [off] 8-bit relative section-crossing relocation + Warns that an 8-bit relative relocation that could + not be resolved at assembly time was generated in + the output format. + + This is usually normal, but may not be handled by all + possible target environments + +reloc-rel-dword [off] 32-bit relative section-crossing relocation + Warns that a 32-bit relative relocation that could + not be resolved at assembly time was generated in + the output format. + + This is usually normal, but may not be handled by all + possible target environments + +reloc-rel-qword [off] 64-bit relative section-crossing relocation + Warns that an 64-bit relative relocation that could + not be resolved at assembly time was generated in + the output format. + + This is usually normal, but may not be handled by all + possible target environments + +reloc-rel-word [off] 16-bit relative section-crossing relocation + Warns that a 16-bit relative relocation that could + not be resolved at assembly time was generated in + the output format. + + This is usually normal, but may not be handled by all + possible target environments + +section-alignment-rounded [on] section alignment rounded up + Warn if a section alignment is specified which is + not supported by the underlying object format, but + can be rounded up to a supported value. + +unknown-warning [off] unknown warning in \c{-W}/\c{-w} or warning directive + Warns about a \c{-w} or \c{-W} option or a \c{[WARNING]} directive + that contains an unknown warning name or is otherwise not possible + to process. + +user [on] \c{%warning} directives + Controls output of \c{%warning} directives (see \k{pperror}). + +warn-stack-empty [on] warning stack empty + A \c{[WARNING POP]} directive was executed when + the warning stack is empty. This is treated + as a \c{[WARNING *all]} directive. + +# +# This warning is currently issued by backends, but in the future +# that code should be centralized. +# +zeroing [on] \c{RES}\e{x} in initialized section becomes zero + A \c{RES}\e{x} directive was used in a section which contains + initialized data, and the output format does not support + this. Instead, this will be replaced with explicit zero + content, which may produce a large output file. + +zext-reloc [on] relocation zero-extended to match output format + Warns that a relocation has been zero-extended due + to limitations in the output format. diff --git a/asm/warnings.pl b/asm/warnings.pl index e4b04d2b..9ac7684b 100755 --- a/asm/warnings.pl +++ b/asm/warnings.pl @@ -43,96 +43,72 @@ sub add_alias($$) { } } -sub find_warnings($$) { - my($srcdir, $infile) = @_; +sub read_warnings($) { + my($infile) = @_; - return unless ($infile =~ /.[ch]$/i); + open(my $in, '<', $infile) or die "$0:$infile: $!\n"; - my $in; - open($in, '<', $infile) - or open($in, '<', File::Spec->catfile($srcdir, $infile)) - or die "$0: cannot open input file $infile: $!\n"; - my $in_comment = 0; my $nline = 0; my $this; my @doc; while (defined(my $l = <$in>)) { $nline++; - chomp $l; - - if (!$in_comment) { - $l =~ s/^.*?\/\*.*?\*\///g; # Remove single-line comments - - if ($l =~ /^.*?(\/\*.*)$/) { - # Begin block comment - $l = $1; - $in_comment = 1; - } + $l =~ s/\s+$//; + if ($l ne '') { + $l =~ s/^\s*\#(\s.*)?$//; + $l =~ s/\s+\\\#(\s.*)?$//; + next if ($l eq ''); } - if ($in_comment) { - if ($l =~ /\*\//) { - # End block comment - $in_comment = 0; - undef $this; - } elsif ($l =~ /^\s*\/?\*\!(\-|\=|\s*)(.*?)\s*$/) { - my $opr = $1; - my $str = $2; + if ($l =~ /^([\w\-]+)\s+\[(\w+)\]\s+(.*)$/) { + my $name = $1; + my $def = $2; + my $help = $3; - if ($opr eq '' && $str eq '') { - next; - } elsif ((!defined($this) || ($opr eq '')) && - ($str =~ /^([\w\-]+)\s+\[(\w+)\]\s(.*\S)\s*$/)) { - my $name = $1; - my $def = $2; - my $help = $3; + my $cname = uc($name); + $cname =~ s/[^A-Z0-9_]+/_/g; - my $cname = uc($name); - $cname =~ s/[^A-Z0-9_]+/_/g; + $this = {name => $name, cname => $cname, + def => $def, help => $help, + doc => [], file => $infile, line => $nline}; - $this = {name => $name, cname => $cname, - def => $def, help => $help, - doc => [], file => $infile, line => $nline}; - - if (defined(my $that = $aliases{$name})) { - # Duplicate definition?! - printf STDERR "%s:%s: warning %s previously defined at %s:%s\n", - $infile, $nline, $name, $that->{file}, $that->{line}; - } else { - push(@warnings, $this); - # Every warning name is also a valid warning alias - add_alias($name, $this); - $nwarn++; - } - } elsif ($opr eq '=') { - # Alias names for warnings - for my $a (split(/,+/, $str)) { - add_alias($a, $this); - } - } elsif ($opr =~ /^[\-\s]/) { - push(@{$this->{doc}}, "$str\n"); - } else { - print STDERR "$infile:$nline: malformed warning definition\n"; - print STDERR " $l\n"; - $err++; - } + if (defined(my $that = $aliases{$name})) { + # Duplicate definition?! + printf STDERR "%s:%s: warning %s previously defined at %s:%s\n", + $infile, $nline, $name, $that->{file}, $that->{line}; } else { - undef $this; + push(@warnings, $this); + # Every warning name is also a valid warning alias + add_alias($name, $this); + $nwarn++; } + } elsif ($l =~ /^\=([\w\-,]+)$/) { + # Alias names for warnings + die unless (defined($this)); + map { add_alias($_,$this) } split(/,+/, $1); + } elsif ($l =~ /^(\s+(.*))?$/) { + my $str = $2; + die unless (defined($this)); + next if ($str eq '' && !scalar(@{$this->{doc}})); + push(@{$this->{doc}}, "$str\n"); + } else { + print STDERR "$infile:$nline: malformed warning definition\n"; + print STDERR " $l\n"; + $err++; } } close($in); } -my($what, $outfile, $srcdir, @infiles) = @ARGV; +my($what, $outfile, @infiles) = @ARGV; if (!defined($outfile)) { - die "$0: usage: [c|h|doc] outfile srcdir infiles...\n"; + die "$0: usage: [c|h|doc] outfile infiles...\n"; } foreach my $file (@infiles) { - find_warnings($srcdir, $file); + read_warnings($file); } exit(1) if ($err); @@ -145,8 +121,7 @@ sub sort_warnings { } @warnings = sort sort_warnings @warnings; -my @warn_noall = @warnings; -pop @warn_noall if ($warn_noall[$#warn_noall]->{name} eq 'all'); +my @warn_noall = grep { !($_->{name} eq 'all') } @warnings; my $outdata; open(my $out, '>', \$outdata) @@ -237,40 +212,32 @@ if ($what eq 'c') { $#warn_noall + 2; print $out "\n#endif /* $guard */\n"; } elsif ($what eq 'doc') { - my %whatdef = ( 'on' => 'Enabled', - 'off' => 'Disabled', - 'err' => 'Enabled and promoted to error' ); + my %wsec = ('on' => [], 'off' => [], 'err' => [], + 'group' => [], 'legacy' => []); my @indexinfo = (); - my @outtxt = (); foreach my $pfx (sort { $a cmp $b } keys(%prefixes)) { my $warn = $aliases{$pfx}; my @doc; + my $wtxt; if (!defined($warn)) { my @plist = sort { $a cmp $b } @{$prefixes{$pfx}}; next if ( $#plist < 1 ); - @doc = ("all \\c{$pfx-} warnings\n\n", - "\\> \\c{$pfx} is a group alias for all warning classes\n", - "prefixed by \\c{$pfx-}; currently\n"); - # Just commas is bad grammar to be sure, but it is more - # legible than the alternative. - push(@doc, join(scalar(@plist) < 3 ? ' and ' : ', ', - map { "\\c{$_}" } @plist).".\n"); + @doc = ("group alias for:\n\n"); + push(@doc, map { "\\c $_\n" } @plist); + $wtxt = $wsec{'group'}; } elsif ($pfx ne $warn->{name}) { my $awarn = $aliases{$warn->{name}}; @doc = ($awarn->{help}."\n\n", - "\\> \\c{$pfx} is a backwards compatibility alias for \\c{". - $warn->{name}."}.\n"); + "\\> Alias for \\c{".$warn->{name}."}.\n"); + $wtxt = $wsec{'legacy'}; } else { - my $docdef = $whatdef{$warn->{def}}; + @doc = ($warn->{help}."\n\n"); - @doc = ($warn->{help}."\n\n", - "\\> \\c{".$warn->{name}."} "); - - my $newpara = 0; + my $newpara = 1; foreach my $l (@{$warn->{doc}}) { if ($l =~ /^\s*$/) { $newpara = 1; @@ -282,16 +249,41 @@ if ($what eq 'c') { } push(@doc, $l); } - if (defined($docdef)) { - push(@doc, "\n", "\\> $docdef by default.\n"); - } + + $wtxt = $wsec{$warn->{def}}; } push(@indexinfo, "\\IR{w-$pfx} warning class, \\c{$pfx}\n"); - push(@outtxt, "\\b \\I{w-$pfx} \\c{$pfx}: ", @doc, "\n"); + push(@$wtxt, "\\b \\I{w-$pfx} \\c{$pfx}: ", @doc, "\n"); } - print $out "\n", @indexinfo, "\n", @outtxt; + print $out "\n", @indexinfo, "\n"; + print $out "\n\\H{warning-classes} Warning Classes\n\n"; + print $out "This list shows each warning class that can be\n"; + print $out "enabled or disabled individually. Each warning containing\n"; + print $out "a \\c{-} character in the name can also be enabled or\n"; + print $out "disabled as part of a group, named by removing one or more\n"; + print $out "\\c{-}-delimited suffixes.\n"; + + print $out "\n\\S{warnings-classes-on} Enabled by default\n\n"; + print $out @{$wsec{'on'}}; + + print $out "\n\\S{warnings-classes-err} Enabled and promoted to error by default\n\n"; + print $out @{$wsec{'err'}}; + + print $out "\n\\S{warnings-classes-off} Disabled by default\n\n"; + print $out @{$wsec{'off'}}; + + print $out "\n\\H{warning-groups} Warning Class Groups\n\n"; + print $out "Warning class groups are aliases for all warning classes with a common\n"; + print $out "prefix. This list shows the warnings that are currently\n"; + print $out "included in specific warning groups.\n\n"; + print $out @{$wsec{'group'}}; + + print $out "\n\\H{warning-legacy} Warning Class Aliases for Backward Compatiblity\n\n"; + print $out "These aliases are defined for compatibility with earlier\n"; + print $out "versions of NASM.\n\n"; + print $out @{$wsec{'legacy'}}; } close($out); diff --git a/nasmlib/readnum.c b/nasmlib/readnum.c index e955b779..8cf2a0a8 100644 --- a/nasmlib/readnum.c +++ b/nasmlib/readnum.c @@ -17,14 +17,6 @@ void warn_dollar_hex(void) { - /*! - *!number-deprecated-hex [on] $ prefix for hexadecimal is deprecated - *! warns that the \c{$} prefix for hexadecimal numbers is - *! deprecated, due to the syntactic conflict with \c{$} used - *! as a symbol escape prefix. This syntax may be disabled by - *! default in a future version of NASM. Replace \c{$} with \c{0x} - *! to ensure compatibility with future versions. - */ nasm_warn(WARN_NUMBER_DEPRECATED_HEX, "$ prefix for hexadecimal is deprecated"); } @@ -129,11 +121,6 @@ int64_t readnum(const char *str, bool *error) } if (warn) { - /*! - *!number-overflow [on] numeric constant does not fit - *! covers warnings about numeric constants which - *! don't fit in 64 bits. - */ nasm_warn(WARN_NUMBER_OVERFLOW, "numeric constant %s does not fit in 64 bits", str); diff --git a/output/outobj.c b/output/outobj.c index 5645928e..2ec416b9 100644 --- a/output/outobj.c +++ b/output/outobj.c @@ -1319,12 +1319,6 @@ static uint32_t check_segment_alignment(const uint64_t origalign) while (!(align & alignments)) align <<= 1; - /*! - *!section-alignment-rounded [on] section alignment rounded up - *! warn if a section alignment is specified which is - *! not supported by the underlying object format, but - *! can be rounded up to a supported value. - */ nasm_warn(WARN_SECTION_ALIGNMENT_ROUNDED, "alignment of %"PRIu64" not supported, using %"PRIu32, origalign, align);