From 730fdd725fb8ca25f5fe9e9e69995d7c022fd78e Mon Sep 17 00:00:00 2001 From: Peter Johnson Date: Thu, 3 Nov 2005 03:49:10 +0000 Subject: [PATCH] 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 --- frontends/yasm/yasm.c | 27 ++++++++++++--------------- libyasm/errwarn.c | 3 ++- libyasm/errwarn.h | 3 ++- modules/objfmts/bin/bin-objfmt.c | 2 +- modules/objfmts/coff/coff-objfmt.c | 2 +- modules/objfmts/elf/elf-objfmt.c | 2 +- modules/objfmts/xdf/xdf-objfmt.c | 2 +- 7 files changed, 20 insertions(+), 21 deletions(-) diff --git a/frontends/yasm/yasm.c b/frontends/yasm/yasm.c index 55e18ff5..22b6c2bc 100644 --- a/frontends/yasm/yasm.c +++ b/frontends/yasm/yasm.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; diff --git a/libyasm/errwarn.c b/libyasm/errwarn.c index 03e7b1b5..e8c37905 100644 --- a/libyasm/errwarn.c +++ b/libyasm/errwarn.c @@ -100,7 +100,8 @@ yasm_errwarn_initialize(void) /* Default enabled warnings. See errwarn.h for a list. */ warn_class_enabled = (1UL<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); diff --git a/modules/objfmts/coff/coff-objfmt.c b/modules/objfmts/coff/coff-objfmt.c index 15d530e6..30210331 100644 --- a/modules/objfmts/coff/coff-objfmt.c +++ b/modules/objfmts/coff/coff-objfmt.c @@ -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); diff --git a/modules/objfmts/elf/elf-objfmt.c b/modules/objfmts/elf/elf-objfmt.c index fa0604f7..8bacc6e1 100644 --- a/modules/objfmts/elf/elf-objfmt.c +++ b/modules/objfmts/elf/elf-objfmt.c @@ -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); diff --git a/modules/objfmts/xdf/xdf-objfmt.c b/modules/objfmts/xdf/xdf-objfmt.c index 8aa8e089..317f08eb 100644 --- a/modules/objfmts/xdf/xdf-objfmt.c +++ b/modules/objfmts/xdf/xdf-objfmt.c @@ -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); -- 2.40.0