0
0
mirror of https://github.com/netwide-assembler/nasm.git synced 2025-09-22 10:43:39 -04:00

error: Style liftup

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
This commit is contained in:
Cyrill Gorcunov
2018-11-24 18:58:11 +03:00
parent 85261a2b57
commit 3351072306
2 changed files with 166 additions and 163 deletions

View File

@@ -47,92 +47,94 @@
* the [warning] directive.
*/
const struct warning warnings[ERR_WARN_ALL+1] = {
{"other", "any warning not specifially mentioned below", true},
{"macro-params", "macro calls with wrong parameter count", true},
{"macro-selfref", "cyclic macro references", false},
{"macro-defaults", "macros with more default than optional parameters", true},
{"orphan-labels", "labels alone on lines without trailing `:'", true},
{"number-overflow", "numeric constant does not fit", true},
{"gnu-elf-extensions", "using 8- or 16-bit relocation in ELF32, a GNU extension", false},
{"float-overflow", "floating point overflow", true},
{"float-denorm", "floating point denormal", false},
{"float-underflow", "floating point underflow", false},
{"float-toolong", "too many digits in floating-point number", true},
{"user", "%warning directives", true},
{"lock", "lock prefix on unlockable instructions", true},
{"hle", "invalid hle prefixes", true},
{"bnd", "invalid bnd prefixes", true},
{"zext-reloc", "relocation zero-extended to match output format", true},
{"ptr", "non-NASM keyword used in other assemblers", true},
{"bad-pragma", "empty or malformed %pragma", false},
{"unknown-pragma", "unknown %pragma facility or directive", false},
{"not-my-pragma", "%pragma not applicable to this compilation", false},
{"unknown-warning", "unknown warning in -W/-w or warning directive", false},
{"negative-rep", "regative %rep count", true},
{"phase", "phase error during stabilization", false},
{ "other", "any warning not specifially mentioned below", true },
{ "macro-params", "macro calls with wrong parameter count", true },
{ "macro-selfref", "cyclic macro references", false },
{ "macro-defaults", "macros with more default than optional parameters", true },
{ "orphan-labels", "labels alone on lines without trailing `:'", true },
{ "number-overflow", "numeric constant does not fit", true },
{ "gnu-elf-extensions", "using 8- or 16-bit relocation in ELF32, a GNU extension", false },
{ "float-overflow", "floating point overflow", true },
{ "float-denorm", "floating point denormal", false },
{ "float-underflow", "floating point underflow", false },
{ "float-toolong", "too many digits in floating-point number", true },
{ "user", "%warning directives", true },
{ "lock", "lock prefix on unlockable instructions", true },
{ "hle", "invalid hle prefixes", true },
{ "bnd", "invalid bnd prefixes", true },
{ "zext-reloc", "relocation zero-extended to match output format", true },
{ "ptr", "non-NASM keyword used in other assemblers", true },
{ "bad-pragma", "empty or malformed %pragma", false },
{ "unknown-pragma", "unknown %pragma facility or directive", false },
{ "not-my-pragma", "%pragma not applicable to this compilation", false },
{ "unknown-warning", "unknown warning in -W/-w or warning directive", false },
{ "negative-rep", "regative %rep count", true },
{ "phase", "phase error during stabilization", false },
/* THIS ENTRY MUST COME LAST */
{"all", "all possible warnings", false}
/* THIS ENTRY MUST COME LAST */
{ "all", "all possible warnings", false }
};
uint8_t warning_state[ERR_WARN_ALL];/* Current state */
uint8_t warning_state_init[ERR_WARN_ALL]; /* Command-line state, for reset */
/* Current state and command-line state, for reset */
uint8_t warning_state[ERR_WARN_ALL];
uint8_t warning_state_init[ERR_WARN_ALL];
vefunc nasm_verror; /* Global error handling function */
/* Global error handling function */
vefunc nasm_verror;
void nasm_error(int severity, const char *fmt, ...)
{
va_list ap;
va_list ap;
va_start(ap, fmt);
nasm_verror(severity, fmt, ap);
va_end(ap);
va_start(ap, fmt);
nasm_verror(severity, fmt, ap);
va_end(ap);
}
fatal_func nasm_fatal(const char *fmt, ...)
{
va_list ap;
va_list ap;
va_start(ap, fmt);
nasm_verror(ERR_FATAL, fmt, ap);
abort(); /* We should never get here */
va_start(ap, fmt);
nasm_verror(ERR_FATAL, fmt, ap);
abort();
}
fatal_func nasm_fatal_fl(int flags, const char *fmt, ...)
{
va_list ap;
va_list ap;
va_start(ap, fmt);
nasm_verror(flags | ERR_FATAL, fmt, ap);
abort(); /* We should never get here */
va_start(ap, fmt);
nasm_verror(flags | ERR_FATAL, fmt, ap);
abort();
}
fatal_func nasm_panic(const char *fmt, ...)
{
va_list ap;
va_list ap;
va_start(ap, fmt);
nasm_verror(ERR_PANIC, fmt, ap);
abort(); /* We should never get here */
va_start(ap, fmt);
nasm_verror(ERR_PANIC, fmt, ap);
abort();
}
fatal_func nasm_panic_fl(int flags, const char *fmt, ...)
{
va_list ap;
va_list ap;
va_start(ap, fmt);
nasm_verror(flags | ERR_PANIC, fmt, ap);
abort(); /* We should never get here */
va_start(ap, fmt);
nasm_verror(flags | ERR_PANIC, fmt, ap);
abort();
}
fatal_func nasm_panic_from_macro(const char *file, int line)
{
nasm_panic("internal error at %s:%d\n", file, line);
nasm_panic("internal error at %s:%d\n", file, line);
}
fatal_func nasm_assert_failed(const char *file, int line, const char *msg)
{
nasm_panic("assertion %s failed at %s:%d", msg, file, line);
nasm_panic("assertion %s failed at %s:%d", msg, file, line);
}
/*
@@ -141,82 +143,82 @@ fatal_func nasm_assert_failed(const char *file, int line, const char *msg)
*/
bool set_warning_status(const char *value)
{
enum warn_action { WID_OFF, WID_ON, WID_RESET };
enum warn_action action;
uint8_t mask;
int i;
bool ok = false;
enum warn_action { WID_OFF, WID_ON, WID_RESET };
enum warn_action action;
bool ok = false;
uint8_t mask;
int i;
value = nasm_skip_spaces(value);
switch (*value) {
case '-':
action = WID_OFF;
value++;
break;
case '+':
action = WID_ON;
value++;
break;
case '*':
action = WID_RESET;
value++;
break;
case 'N':
case 'n':
if (!nasm_strnicmp(value, "no-", 3)) {
action = WID_OFF;
value += 3;
break;
} else if (!nasm_stricmp(value, "none")) {
action = WID_OFF;
value = NULL;
break;
}
/* else fall through */
default:
action = WID_ON;
break;
}
value = nasm_skip_spaces(value);
switch (*value) {
case '-':
action = WID_OFF;
value++;
break;
case '+':
action = WID_ON;
value++;
break;
case '*':
action = WID_RESET;
value++;
break;
case 'N':
case 'n':
if (!nasm_strnicmp(value, "no-", 3)) {
action = WID_OFF;
value += 3;
break;
} else if (!nasm_stricmp(value, "none")) {
action = WID_OFF;
value = NULL;
break;
}
/* else fall through */
default:
action = WID_ON;
break;
}
mask = WARN_ST_ENABLED;
mask = WARN_ST_ENABLED;
if (value && !nasm_strnicmp(value, "error", 5)) {
switch (value[5]) {
case '=':
mask = WARN_ST_ERROR;
value += 6;
break;
case '\0':
mask = WARN_ST_ERROR;
value = NULL;
break;
default:
/* Just an accidental prefix? */
break;
}
}
if (value && !nasm_strnicmp(value, "error", 5)) {
switch (value[5]) {
case '=':
mask = WARN_ST_ERROR;
value += 6;
break;
case '\0':
mask = WARN_ST_ERROR;
value = NULL;
break;
default:
/* Just an accidental prefix? */
break;
}
}
if (value && !nasm_stricmp(value, "all"))
value = NULL;
if (value && !nasm_stricmp(value, "all"))
value = NULL;
/* This is inefficient, but it shouldn't matter... */
for (i = 0; i < ERR_WARN_ALL; i++) {
if (!value || !nasm_stricmp(value, warnings[i].name)) {
ok = true; /* At least one action taken */
switch (action) {
case WID_OFF:
warning_state[i] &= ~mask;
break;
case WID_ON:
warning_state[i] |= mask;
break;
case WID_RESET:
warning_state[i] &= ~mask;
warning_state[i] |= warning_state_init[i] & mask;
break;
}
}
}
/* This is inefficient, but it shouldn't matter... */
for (i = 0; i < ERR_WARN_ALL; i++) {
if (!value || !nasm_stricmp(value, warnings[i].name)) {
ok = true; /* At least one action taken */
switch (action) {
case WID_OFF:
warning_state[i] &= ~mask;
break;
case WID_ON:
warning_state[i] |= mask;
break;
case WID_RESET:
warning_state[i] &= ~mask;
warning_state[i] |= warning_state_init[i] & mask;
break;
}
}
}
return ok;
return ok;
}

View File

@@ -53,11 +53,12 @@ fatal_func nasm_panic_from_macro(const char *file, int line);
typedef void (*vefunc) (int severity, const char *fmt, va_list ap);
extern vefunc nasm_verror;
static inline vefunc nasm_set_verror(vefunc ve)
{
vefunc old_verror = nasm_verror;
nasm_verror = ve;
return old_verror;
vefunc old_verror = nasm_verror;
nasm_verror = ve;
return old_verror;
}
/*
@@ -65,46 +66,46 @@ static inline vefunc nasm_set_verror(vefunc ve)
* argument to an efunc.
*/
#define ERR_DEBUG 0x00000000 /* put out debugging message */
#define ERR_WARNING 0x00000001 /* warn only: no further action */
#define ERR_NONFATAL 0x00000002 /* terminate assembly after phase */
#define ERR_FATAL 0x00000006 /* instantly fatal: exit with error */
#define ERR_PANIC 0x00000007 /* internal error: panic instantly
* and dump core for reference */
#define ERR_MASK 0x00000007 /* mask off the above codes */
#define ERR_NOFILE 0x00000010 /* don't give source file name/line */
#define ERR_TOPFILE 0x00000020 /* give the top input file name only */
#define ERR_USAGE 0x00000040 /* print a usage message */
#define ERR_PASS1 0x00000080 /* only print this error on pass one */
#define ERR_PASS2 0x00000100 /* only print this error on pass one */
#define ERR_DEBUG 0x00000000 /* put out debugging message */
#define ERR_WARNING 0x00000001 /* warn only: no further action */
#define ERR_NONFATAL 0x00000002 /* terminate assembly after phase */
#define ERR_FATAL 0x00000006 /* instantly fatal: exit with error */
#define ERR_PANIC 0x00000007 /* internal error: panic instantly
* and dump core for reference */
#define ERR_MASK 0x00000007 /* mask off the above codes */
#define ERR_NOFILE 0x00000010 /* don't give source file name/line */
#define ERR_TOPFILE 0x00000020 /* give the top input file name only */
#define ERR_USAGE 0x00000040 /* print a usage message */
#define ERR_PASS1 0x00000080 /* only print this error on pass one */
#define ERR_PASS2 0x00000100 /* only print this error on pass one */
#define ERR_NO_SEVERITY 0x00000200 /* suppress printing severity */
#define ERR_PP_PRECOND 0x00000400 /* for preprocessor use */
#define ERR_PP_LISTMACRO 0x00000800 /* from preproc->error_list_macros() */
#define ERR_NO_SEVERITY 0x00000200 /* suppress printing severity */
#define ERR_PP_PRECOND 0x00000400 /* for preprocessor use */
#define ERR_PP_LISTMACRO 0x00000800 /* from preproc->error_list_macros() */
/*
* These codes define specific types of suppressible warning.
*/
#define ERR_WARN_MASK 0xFFFFF000 /* the mask for this feature */
#define ERR_WARN_SHR 12 /* how far to shift right */
#define ERR_WARN_MASK 0xFFFFF000 /* the mask for this feature */
#define ERR_WARN_SHR 12 /* how far to shift right */
#define WARN(x) ((x) << ERR_WARN_SHR)
#define WARN_IDX(x) (((x) & ERR_WARN_MASK) >> ERR_WARN_SHR)
#define WARN(x) ((x) << ERR_WARN_SHR)
#define WARN_IDX(x) (((x) & ERR_WARN_MASK) >> ERR_WARN_SHR)
#define ERR_WARN_OTHER WARN( 0) /* any noncategorized warning */
#define ERR_WARN_MNP WARN( 1) /* macro-num-parameters warning */
#define ERR_WARN_MSR WARN( 2) /* macro self-reference */
#define ERR_WARN_MDP WARN( 3) /* macro default parameters check */
#define ERR_WARN_OL WARN( 4) /* orphan label (no colon, and
#define ERR_WARN_OTHER WARN( 0) /* any noncategorized warning */
#define ERR_WARN_MNP WARN( 1) /* macro-num-parameters warning */
#define ERR_WARN_MSR WARN( 2) /* macro self-reference */
#define ERR_WARN_MDP WARN( 3) /* macro default parameters check */
#define ERR_WARN_OL WARN( 4) /* orphan label (no colon, and
* alone on line) */
#define ERR_WARN_NOV WARN( 5) /* numeric overflow */
#define ERR_WARN_GNUELF WARN( 6) /* using GNU ELF extensions */
#define ERR_WARN_FL_OVERFLOW WARN( 7) /* FP overflow */
#define ERR_WARN_FL_DENORM WARN( 8) /* FP denormal */
#define ERR_WARN_FL_UNDERFLOW WARN( 9) /* FP underflow */
#define ERR_WARN_FL_TOOLONG WARN(10) /* FP too many digits */
#define ERR_WARN_USER WARN(11) /* %warning directives */
#define ERR_WARN_NOV WARN( 5) /* numeric overflow */
#define ERR_WARN_GNUELF WARN( 6) /* using GNU ELF extensions */
#define ERR_WARN_FL_OVERFLOW WARN( 7) /* FP overflow */
#define ERR_WARN_FL_DENORM WARN( 8) /* FP denormal */
#define ERR_WARN_FL_UNDERFLOW WARN( 9) /* FP underflow */
#define ERR_WARN_FL_TOOLONG WARN(10) /* FP too many digits */
#define ERR_WARN_USER WARN(11) /* %warning directives */
#define ERR_WARN_LOCK WARN(12) /* bad LOCK prefixes */
#define ERR_WARN_HLE WARN(13) /* bad HLE prefixes */
#define ERR_WARN_BND WARN(14) /* bad BND prefixes */
@@ -118,23 +119,23 @@ static inline vefunc nasm_set_verror(vefunc ve)
#define ERR_WARN_PHASE WARN(22) /* phase error in pass 1 */
/* The "all" warning acts as a global switch, it must come last */
#define ERR_WARN_ALL 23 /* Do not use WARN() here */
#define ERR_WARN_ALL 23 /* Do not use WARN() here */
struct warning {
const char *name;
const char *help;
bool enabled;
const char *name;
const char *help;
bool enabled;
};
extern const struct warning warnings[ERR_WARN_ALL+1];
/* This is a bitmask */
#define WARN_ST_ENABLED 1 /* Warning is currently enabled */
#define WARN_ST_ERROR 2 /* Treat this warning as an error */
#define WARN_ST_ENABLED 1 /* Warning is currently enabled */
#define WARN_ST_ERROR 2 /* Treat this warning as an error */
extern uint8_t warning_state[ERR_WARN_ALL];
extern uint8_t warning_state_init[ERR_WARN_ALL];
/* Process a warning option or directive */
bool set_warning_status(const char *);
bool set_warning_status(const char *value);
#endif /* NASM_ERROR_H */