Add warning class (YASM_WARN_UNINIT_CONTENTS) to turn off the

"uninitialized data in code/data section: zeroing" warning.  This can now
be turned off using -Wno-uninit-contents on the command line.

* errwarn.h (yasm_warn_class): Add warning class.
* errwarn.c (yasm_errwarn_initialize): Default it to enabled.

* yasm.c (opt_warning_handler): Add as option.

* xdf-objfmt.c, elf-objfmt.c, bin-objfmt.c, coff-objfmt.c: Change warning
class for this warning.

svn path=/trunk/yasm/; revision=1307
0.5.0rc2
Peter Johnson 19 years ago
parent bddebf0092
commit 730fdd725f
  1. 27
      frontends/yasm/yasm.c
  2. 3
      libyasm/errwarn.c
  3. 3
      libyasm/errwarn.h
  4. 2
      modules/objfmts/bin/bin-objfmt.c
  5. 2
      modules/objfmts/coff/coff-objfmt.c
  6. 2
      modules/objfmts/elf/elf-objfmt.c
  7. 2
      modules/objfmts/xdf/xdf-objfmt.c

@ -950,7 +950,8 @@ opt_machine_handler(/*@unused@*/ char *cmd, char *param,
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 */
@ -963,26 +964,22 @@ opt_warning_handler(char *cmd, /*@unused@*/ char *param, int extra)
/* 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;

@ -100,7 +100,8 @@ yasm_errwarn_initialize(void)
/* 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;

@ -39,7 +39,8 @@ typedef enum {
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. */

@ -230,7 +230,7 @@ bin_objfmt_output_bytecode(yasm_bytecode *bc, /*@null@*/ void *d)
/* 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);

@ -540,7 +540,7 @@ coff_objfmt_output_bytecode(yasm_bytecode *bc, /*@null@*/ void *d)
/* 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);

@ -439,7 +439,7 @@ elf_objfmt_output_bytecode(yasm_bytecode *bc, /*@null@*/ void *d)
/* 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);

@ -291,7 +291,7 @@ xdf_objfmt_output_bytecode(yasm_bytecode *bc, /*@null@*/ void *d)
/* 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);

Loading…
Cancel
Save