static int
opt_warning_handler(char *cmd, /*@unused@*/ char *param, int extra)
{
- int enable = 1; /* is it disabling the warning instead of enabling? */
+ /* is it disabling the warning instead of enabling? */
+ void (*action)(yasm_warn_class wclass) = yasm_warn_enable;
if (extra == 1) {
/* -w, disable warnings */
/* detect no- prefix to disable the warning */
if (cmd[0] == 'n' && cmd[1] == 'o' && cmd[2] == '-') {
- enable = 0;
+ action = yasm_warn_disable;
cmd += 3; /* skip past it to get to the warning name */
}
if (cmd[0] == '\0')
/* just -W or -Wno-, so definitely not valid */
return 1;
- else if (strcmp(cmd, "error") == 0) {
- warning_error = enable;
- } else if (strcmp(cmd, "unrecognized-char") == 0) {
- if (enable)
- yasm_warn_enable(YASM_WARN_UNREC_CHAR);
- else
- yasm_warn_disable(YASM_WARN_UNREC_CHAR);
- } else if (strcmp(cmd, "orphan-labels") == 0) {
- if (enable)
- yasm_warn_enable(YASM_WARN_ORPHAN_LABEL);
- else
- yasm_warn_disable(YASM_WARN_ORPHAN_LABEL);
- } else
+ else if (strcmp(cmd, "error") == 0)
+ warning_error = (action == yasm_warn_enable);
+ else if (strcmp(cmd, "unrecognized-char") == 0)
+ action(YASM_WARN_UNREC_CHAR);
+ else if (strcmp(cmd, "orphan-labels") == 0)
+ action(YASM_WARN_ORPHAN_LABEL);
+ else if (strcmp(cmd, "uninit-contents") == 0)
+ action(YASM_WARN_UNINIT_CONTENTS);
+ else
return 1;
return 0;
/* Default enabled warnings. See errwarn.h for a list. */
warn_class_enabled =
(1UL<<YASM_WARN_GENERAL) | (1UL<<YASM_WARN_UNREC_CHAR) |
- (1UL<<YASM_WARN_PREPROC) | (0UL<<YASM_WARN_ORPHAN_LABEL);
+ (1UL<<YASM_WARN_PREPROC) | (0UL<<YASM_WARN_ORPHAN_LABEL) |
+ (1UL<<YASM_WARN_UNINIT_CONTENTS);
error_count = 0;
warning_count = 0;
YASM_WARN_GENERAL = 0, /**< Non-specific warnings */
YASM_WARN_UNREC_CHAR, /**< Unrecognized characters (while tokenizing) */
YASM_WARN_PREPROC, /**< Preprocessor warnings */
- YASM_WARN_ORPHAN_LABEL /**< Label alone on a line without a colon */
+ YASM_WARN_ORPHAN_LABEL, /**< Label alone on a line without a colon */
+ YASM_WARN_UNINIT_CONTENTS /**< Uninitialized space in code/data section */
} yasm_warn_class;
/** Initialize any internal data structures. */
/* Warn that gaps are converted to 0 and write out the 0's. */
if (gap) {
unsigned long left;
- yasm__warning(YASM_WARN_GENERAL, bc->line,
+ yasm__warning(YASM_WARN_UNINIT_CONTENTS, bc->line,
N_("uninitialized space declared in code/data section: zeroing"));
/* Write out in chunks */
memset(info->buf, 0, REGULAR_OUTBUF_SIZE);
/* Warn that gaps are converted to 0 and write out the 0's. */
if (gap) {
unsigned long left;
- yasm__warning(YASM_WARN_GENERAL, bc->line,
+ yasm__warning(YASM_WARN_UNINIT_CONTENTS, bc->line,
N_("uninitialized space declared in code/data section: zeroing"));
/* Write out in chunks */
memset(info->buf, 0, REGULAR_OUTBUF_SIZE);
/* Warn that gaps are converted to 0 and write out the 0's. */
if (gap) {
unsigned long left;
- yasm__warning(YASM_WARN_GENERAL, bc->line,
+ yasm__warning(YASM_WARN_UNINIT_CONTENTS, bc->line,
N_("uninitialized space declared in code/data section: zeroing"));
/* Write out in chunks */
memset(buf, 0, 256);
/* Warn that gaps are converted to 0 and write out the 0's. */
if (gap) {
unsigned long left;
- yasm__warning(YASM_WARN_GENERAL, bc->line,
+ yasm__warning(YASM_WARN_UNINIT_CONTENTS, bc->line,
N_("uninitialized space: zeroing"));
/* Write out in chunks */
memset(info->buf, 0, REGULAR_OUTBUF_SIZE);