asm/error.c: handle -w* during command line parsing

During command line parsing, warning_state_init is NULL as the warning
stack is naturally not set up yet. Furthermore, -w* would mean return
to command-line default, which isn't even defined yet.

Rather than ignoring it or returning an error, do something useful by
allowing -w* to reset to the *compile time* default when specified on
the command line.

Reported-by: <momo-trip@github.com>
Fixes: https://github.com/netwide-assembler/nasm/issues/155
Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
This commit is contained in:
H. Peter Anvin (Intel) 2026-07-07 15:06:21 -07:00
parent 63abf28933
commit 9248a85f97

View file

@ -214,10 +214,18 @@ bool set_warning_status(const char *value)
warning_state[i] |= mask;
break;
case WID_RESET:
{
uint8_t old;
if (warning_state_init)
old = warning_state_init->state[i];
else
old = warning_default[i];
warning_state[i] &= ~mask;
warning_state[i] |= warning_state_init->state[i] & mask;
warning_state[i] |= old & mask;
break;
}
}
}
if (!ok && value) {