mirror of
https://github.com/netwide-assembler/nasm.git
synced 2025-04-12 18:40:23 +08:00
error: macro to bypass disabled warning generation
At least attempt to not spend time generating a warning message that is just going to be suppressed. Signed-off-by: H. Peter Anvin <hpa@zytor.com>
This commit is contained in:
parent
0e7eae99e8
commit
2daa5989ab
@ -81,8 +81,11 @@ nasm_err_helpers(fatal_func, panic, ERR_PANIC)
|
||||
* Strongly discourage warnings without level by require flags on warnings.
|
||||
* This means nasm_warn() is the equivalent of the -f variants of the
|
||||
* other ones.
|
||||
*
|
||||
* This is wrapped in a macro to be able to elide it if the warning is
|
||||
* disabled, hence the extra underscore.
|
||||
*/
|
||||
void nasm_warn(errflags flags, const char *fmt, ...)
|
||||
void nasm_warn_(errflags flags, const char *fmt, ...)
|
||||
{
|
||||
nasm_do_error(ERR_WARNING, flags);
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
/* ----------------------------------------------------------------------- *
|
||||
*
|
||||
* Copyright 1996-2020 The NASM Authors - All Rights Reserved
|
||||
* Copyright 1996-2023 The NASM Authors - All Rights Reserved
|
||||
* See the file AUTHORS included with the NASM distribution for
|
||||
* the specific copyright holders.
|
||||
*
|
||||
@ -60,7 +60,7 @@ void printf_func(1, 2) nasm_debug(const char *fmt, ...);
|
||||
void printf_func(2, 3) nasm_debugf(errflags flags, const char *fmt, ...);
|
||||
void printf_func(1, 2) nasm_info(const char *fmt, ...);
|
||||
void printf_func(2, 3) nasm_infof(errflags flags, const char *fmt, ...);
|
||||
void printf_func(2, 3) nasm_warn(errflags flags, const char *fmt, ...);
|
||||
void printf_func(2, 3) nasm_warn_(errflags flags, const char *fmt, ...);
|
||||
void printf_func(1, 2) nasm_nonfatal(const char *fmt, ...);
|
||||
void printf_func(2, 3) nasm_nonfatalf(errflags flags, const char *fmt, ...);
|
||||
fatal_func printf_func(1, 2) nasm_fatal(const char *fmt, ...);
|
||||
@ -145,6 +145,27 @@ void nasm_error_hold_pop(errhold hold, bool issue);
|
||||
/* Should be included from within error.h only */
|
||||
#include "warnings.h"
|
||||
|
||||
/* True if a warning is enabled, either as a warning or an error */
|
||||
static inline bool warn_active(errflags warn)
|
||||
{
|
||||
enum warn_index wa = WARN_IDX(warn);
|
||||
return unlikely(warning_state[wa] & WARN_ST_ENABLED);
|
||||
}
|
||||
|
||||
#ifdef HAVE_VARIADIC_MACROS
|
||||
|
||||
#define nasm_warn(w, ...) \
|
||||
do { \
|
||||
if (unlikely(warn_active(w))) \
|
||||
nasm_warn_(w, __VA_ARGS__); \
|
||||
} while (0)
|
||||
|
||||
#else
|
||||
|
||||
#define nasm_warn nasm_warn_
|
||||
|
||||
#endif
|
||||
|
||||
/* By defining MAX_DEBUG, we can compile out messages entirely */
|
||||
#ifndef MAX_DEBUG
|
||||
# define MAX_DEBUG (~0U)
|
||||
|
Loading…
x
Reference in New Issue
Block a user