summaryrefslogtreecommitdiff
path: root/include/error.h
Commit message (Collapse)AuthorAgeFilesLines
* BR 3392652: hold smacro expansion warnings until we are sureH. Peter Anvin (Intel)2020-06-041-2/+18
| | | | | | | | Don't issue smacro expansion warnings until we are sure we are actually *done* with the smacro expansion. The last pass of expand_smacro_noreset() gets to commit warnings. Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
* error: replace nasm_verror() indirection with preproc callbackH. Peter Anvin2019-08-281-9/+1
| | | | | | | | | | Since pp_error_list_macros() was introduced, the only need for pp_verror() is to suppress error messages in certain contexts. Replace this function with a preprocessor callback, preproc->pp_suppress_error(), so we can drop the nasm_verror() function pointer entirely. Signed-off-by: H. Peter Anvin <hpa@zytor.com>
* errors: be more robust in handling unexpected fatal errorsH. Peter Anvin2019-08-281-2/+6
| | | | | | | | | | | | | Introduce a new error level, ERR_CRITICAL, beyond which we will minimize the amount of code that will be executed before we die; in particular don't execute any memory allocations, and if we somehow end up recursing, abort() immediately. Basically, "less than panic, more than fatal." At this point this level is used by nasm_alloc_failed(). Signed-off-by: H. Peter Anvin <hpa@zytor.com>
* error.h: fix typo: nasm_intof -> nasm_infofH. Peter Anvin (Intel)2019-08-091-1/+1
| | | | | | | BR 3302593: nasm_infof() prototype misspelled as nasm_intof(). Reported-by: <pushbx@38.de> Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
* Diagnostics: make debug more dynamic, note -> info, add listmsg levelH. Peter Anvin (Intel)2019-08-091-7/+24
| | | | | | | | | | | | | | | | Make debug messages more dynamic by making it easy to conditionalize the messages. Change ERR_NOTE to ERR_INFO which reflects the usage better. Other compilers use note: for additional information. Don't unwind the macro stack with ERR_HERE; it is only going to give confusing results as it will unwind the wrong macro stack. Add ERR_LISTMSG level which is *always* suppressed, but will still appear in the list file. Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
* warnings: add [warning push] and [warning pop]H. Peter Anvin (Intel)2019-01-111-0/+6
| | | | | | Add [warning push] and [warning pop] directives. Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
* Merge tag 'nasm-2.14.03rc1'H. Peter Anvin2018-12-271-0/+1
|\ | | | | | | | | | | | | | | | | | | NASM 2.14.03rc1 Resolved Conflicts: asm/labels.c include/error.h Signed-off-by: H. Peter Anvin <hpa@zytor.com>
| * BR 3392539: some errors can "cascade". Allow suppressing if dead.H. Peter Anvin2018-12-271-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In BR 3392539, the error: helloW.s:18: error: label `rurt' changed during code generation [-w+error=label-redef-late] ... occurs a number of times after we have already issued an error. This is because the erroring instruction computes to a different size during code generation; this causes each subsequent label to cause a phase error. The phase error simply doesn't make much sense to report: if we are already committed to erroring out, it is more likely an error cascade rather than an error in its own right, so just suppress it in that case. Reported-by: <russvz@comcast.net> Signed-off-by: H. Peter Anvin <hpa@zytor.com>
* | With buffered warnings, change the handling of error passesH. Peter Anvin (Intel)2018-12-181-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | With buffered warnings, most warnings *must* be issued on every pass, so ERR_PASS1 is simply wrong in most cases. ERR_PASS1 now means "force this warning to be output even in pass_first(). This is to be used for the case where the warning is only executed in pass_first() code; this is highly discouraged as it means the warnings will not appear in the list file and subsequent passes may make the warning suddenly vanish. ERR_PASS2 just as before suppresses an error or warning unless we are in pass_final(). Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
* | nasm_warnf() -> nasm_warn()H. Peter Anvin (Intel)2018-12-141-2/+1
| | | | | | | | | | | | | | | | We want to strongly encourage writers of warnings to create warning categories, so remove the flagless nasm_warn() and change nasm_warnf() to nasm_warn(). Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
* | warnings: define warning classes at point of usemkwarningsH. Peter Anvin (Intel)2018-12-131-41/+8
| | | | | | | | | | | | | | | | | | | | | | | | It is extremely desirable to allow the user fine-grained control of warnings, but this has been complicated by the fact that a warning class has had to be defined in no less than three places (error.h, error.c, nasmdoc.src) before it can be used in source code. Instead, use a script to define these via magic comments at the point of use. This hopefully will encourage creating new classes as needed. Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
* | errors: change the severity parameter from "int" to "errflags"H. Peter Anvin (Intel)2018-12-131-10/+15
| | | | | | | | | | | | | | Change the severity parameter to the error function from "int" to an unsigned typedef, currently uint32_t. Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
* | warnings: change WARN_MNP -> WARN_MACRO_PARAMSH. Peter Anvin (Intel)2018-12-131-1/+1
| | | | | | | | | | | | | | This one got missed during constant name conversion. Make the constants match the options. Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
* | Merge remote-tracking branch 'origin/nasm-2.14.xx'H. Peter Anvin (Intel)2018-12-131-0/+5
|\ \ | |/ | | | | | | | | | | | | | | | | | | Resolved Conflicts: Makefile.in Mkfiles/msvc.mak Mkfiles/openwcom.mak asm/nasm.c nasmlib/alloc.c Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
| * malloc: handle potential infinite loop in nasm_alloc_failed()H. Peter Anvin (Intel)2018-12-131-0/+5
| | | | | | | | | | | | | | | | | | It is possible on memory exhaustion that nasm_fatal() might cause another allocation error, thus calling nasm_alloc_failed() again. If we find us in nasm_alloc_failed() for a second time, try to get a message out and then call abort(). Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
* | warnings: Make WARN_ constants consistent with -w optionsH. Peter Anvin (Intel)2018-12-121-12/+12
| | | | | | | | | | | | Not only does this make it consistent, but allows for automation. Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
* | Merge remote-tracking branch 'origin/nasm-2.14.xx'H. Peter Anvin (Intel)2018-12-121-31/+32
|\ \ | |/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Resolved Conflicts: asm/assemble.c asm/directiv.c asm/error.c asm/float.c asm/labels.c asm/listing.c asm/nasm.c asm/parser.c asm/preproc.c asm/stdscan.c include/error.h output/outelf.c version Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
| * error: new flag ERR_HEREH. Peter Anvin2018-12-121-0/+1
| | | | | | | | | | | | | | | | | | | | | | ERR_HERE is used to mark messages of the form "... here" so that we can emit sane output to the list file with filename and line number, instead of a nonsensical "here" which could point almost anywhere. This patch contains some changes from the one in the master branch to make the code cleaner. Signed-off-by: H. Peter Anvin <hpa@zytor.com>
| * error: remove unused ERR_TOPFILEH. Peter Anvin2018-12-121-1/+0
| | | | | | | | | | | | The flag ERR_TOPFILE was not used anywhere, remove it. Signed-off-by: H. Peter Anvin <hpa@zytor.com>
| * BR 3392535: warning on redefine, promote define-on-pass2 to errorH. Peter Anvin (Intel)2018-12-121-3/+4
| | | | | | | | | | | | | | | | | | | | If we redefine consistently, make it a suppressed-by-default warning. If we end up doing the define on pass 2, promote that to a default-error warning; using a default-error warning allows the user to demote it should they so wish. Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com> Requested-by: C. Masloch <pushbx@38.de>
| * warnings: make it possible for a warning to default to an errorH. Peter Anvin (Intel)2018-12-121-6/+5
| | | | | | | | | | | | | | | | This allows us to do soft-migration of warnings to errors; they will now be nonfatal errors by default, but gives the user the option to demote them. Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
| * warnings; move WARN_OTHER to the end; allow non-warnings to be suppressedH. Peter Anvin (Intel)2018-12-121-22/+23
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Putting WARN_OTHER at the end of the list creates a number of advantages and simplifications: 1. It is more user friendly! It is far more of a logical location for the default case to be at the end of the printed list. 2. The value 0 can be used in a number of places to indicate a non-suppressible event. By having warning_state[0] always contain WARN_ST_ENABLED, we can always do the table lookup, even. 3. It means non-warnings (except fatal/panic) can now be conditioned on warning states. In those cases, WARN_*, including WARN_OTHER, can be added to the mask for any category. This is especially useful for notes. The only downside is that we have to explicitly detect the case where we have ERR_WARNING but no WARN_ flag. This is a trivial test. Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
| * warnings: rename ERR_WARN_* to WARN_*H. Peter Anvin (Intel)2018-12-121-32/+32
| | | | | | | | | | | | | | | | The prefix ERR_WARN_ is unnecessarily long and may be a disincentive to create new warning categories. Change it to WARN_*, it is still plenty distinctive. Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
* | warnings: rename ERR_WARN_* to WARN_*H. Peter Anvin (Intel)2018-12-121-31/+31
| | | | | | | | | | | | | | | | | | | | The prefix ERR_WARN_ is unnecessarily long and may be a disincentive to create new warning categories. Change it to WARN_*, it is still plenty distinctive. This is equivalent to nasm-2.14.xx checkin 77f53ba6d4cb90e5a7e09b33357ed7c1fe9f6b9d. Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
* | error: new flag ERR_HEREH. Peter Anvin2018-12-111-0/+1
| | | | | | | | | | | | | | | | ERR_HERE is used to mark messages of the form "... here" so that we can emit sane output to the list file with filename and line number, instead of a nonsensical "here" which could point almost anywhere. Signed-off-by: H. Peter Anvin <hpa@zytor.com>
* | error: remove unused ERR_TOPFILEH. Peter Anvin2018-12-101-1/+0
| | | | | | | | | | | | The flag ERR_TOPFILE was not used anywhere, remove it. Signed-off-by: H. Peter Anvin <hpa@zytor.com>
* | error: add nasm_note() helper, clean up helper generationH. Peter Anvin2018-12-101-0/+2
| | | | | | | | | | | | | | | | | | It is fairly easy to more compactly create error helpers since we are using preprocessor hacks anyway, so do exactly that. Create nasm_note() helpers for the new NOTE severity class. Signed-off-by: H. Peter Anvin <hpa@zytor.com>
* | Merge remote-tracking branch 'origin/nasm-2.14.xx'H. Peter Anvin2018-12-101-2/+3
|\ \ | |/ | | | | | | | | | | Resolved Conflicts: asm/labels.c include/error.h version
| * error: add new severity level "note"H. Peter Anvin2018-12-101-4/+5
| | | | | | | | | | | | | | Add a new severity level "note", intended to be used to give additional information about a previous error. Signed-off-by: H. Peter Anvin <hpa@zytor.com>
* | error: Cover all levels with helpersCyrill Gorcunov2018-11-251-2/+8
| | | | | | | | Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
* | error: Style liftupCyrill Gorcunov2018-11-241-42/+43
| | | | | | | | Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
* | Merge branch 'nasm-2.14.xx'Cyrill Gorcunov2018-10-151-1/+2
|\ \ | |/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * nasm-2.14.xx: (83 commits) NASM 2.14rc16 doc: Update changes preproc: expand_smacro -- Fix nil dereference on error path eval: Eliminate division by zero doc: Update changes opflags: Convert is_class and is_reg_class to helpers preproc: Fix out of range access in expand mmacro doc: Update changes parser: Fix sigsegv on certain equ instruction parsing labels: Make sure nil label is never passed labels: Don't nil dereference if no label provided macho: Add warning message in macho_output() macho/reloc: Fix addr size sensitive conditions macho/reloc: Fix macho_output() to get the offset adjustments by add_reloc() macho/reloc: Fixed offset adjustment in add_reloc() macho/reloc: Allow absolute relocation when forcing a symbol reference macho/reloc: Adjust SUB relocation information macho/reloc: Fixed in handling GOT/GOTLOAD/TLV relocations macho/reloc: Simplified relocation for REL/BRANCH macho/sym: Record initial symbol number always ... Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
| * asm: add a default-off warning for phase error in pass 1H. Peter Anvin (Intel)2018-06-271-1/+2
| | | | | | | | | | | | | | | | | | Add a default-off warning for phase error in pass 1. This is default off because of the lateness in the release cycle, but cases where we have such instability should be investigated further. For now, the warning is here so we can debug these problems in the field. Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
* | errors: simplify nasm_fatal() and nasm_panic()H. Peter Anvin2018-06-151-3/+5
|/ | | | | | | | | | | | | | | Nearly all instances of nasm_fatal() and nasm_panic() take a flags argument of zero. Simplify the code by making nasm_fatal and nasm_panic default to no flags, and add an alternate version if flags really are desired. This also means that every call site doesn't have to initialize a zero argument. Furthermore, ERR_NOFILE is now often not necessary, as the error code will no longer cause a null reference if there is no current file. Therefore, we can remove many instances of ERR_NOFILE which only deprives the user of information. Signed-off-by: H. Peter Anvin <hpa@zytor.com>
* Make any execution limit configurable, add eval limitH. Peter Anvin2018-06-121-1/+2
| | | | | | | Make any "deadman"-style execution limit configurable on the command line (--limit-foo) or via a pragma (%pragma limit foo). Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
* Introduce cold function attributeH. Peter Anvin2018-02-221-3/+3
| | | | | | Attribute to deemphasize certain code paths. Signed-off-by: H. Peter Anvin <hpa@zytor.com>
* error: add ERR_TOPFILEH. Peter Anvin2017-12-201-7/+8
| | | | | | | | Add ERR_TOPFILE, for cases where displaying the current file and line are completely inappropriate. Instead, display the main input file, or, if not available, the output file. Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
* Make -Werror controllable on a per-warning-class basisH. Peter Anvin2017-03-081-6/+16
| | | | | | | | | | | | Make -Werror possible to control on a per-warning-class basis. While I was fixing up that code anyway, merge the handling of the -w, -W and [warning] argument and directives. Furthermore, make *all* warnings suppressible; any warning that isn't categorized now belong to category "other". However, for cleanliness sake an "other" option does not get listed in the warning messages. Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
* Add a generic pragma-handling infrastructureH. Peter Anvin2017-03-071-1/+4
| | | | | | | Add infrastructure for handling %pragmas with a variety of namespaces, etc., etc... Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
* include/error.h: add file missing from previous commitH. Peter Anvin2017-03-071-0/+122
The include file include/error.h was missing from checkin b20bc733c93f9f4fd3ba44dd6af36dc3b578d041, oops... Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>