]> granicus.if.org Git - yasm/commitdiff
Add warning class (YASM_WARN_UNINIT_CONTENTS) to turn off the
authorPeter Johnson <peter@tortall.net>
Thu, 3 Nov 2005 03:49:10 +0000 (03:49 -0000)
committerPeter Johnson <peter@tortall.net>
Thu, 3 Nov 2005 03:49:10 +0000 (03:49 -0000)
"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
libyasm/errwarn.c
libyasm/errwarn.h
modules/objfmts/bin/bin-objfmt.c
modules/objfmts/coff/coff-objfmt.c
modules/objfmts/elf/elf-objfmt.c
modules/objfmts/xdf/xdf-objfmt.c

index 55e18ff5d0f7a73d38e985c568a3111023ff224e..22b6c2bc2b810f26d19ddf91697a0d55db70cfbd 100644 (file)
@@ -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;
index 03e7b1b537bf138e9defb483820347926ae14d6e..e8c379055934439b4c6c7d06fea588242a6b0afe 100644 (file)
@@ -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;
index aa249b9a70a5f9fc92b46b3c882e565ef1815a39..dc05f705eb9cdb0543845d650c508527e356c4e1 100644 (file)
@@ -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. */
index 53a0e2dcda5d3cc54b546216385721bc4f4af110..8c8f4182fb717c53b68599ba1cae828e287a7313 100644 (file)
@@ -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);
index 15d530e6be8049be0ec2da3d1cacd8547f9a4ccb..30210331e9467fd8a5392ee4176ee64c99e2944b 100644 (file)
@@ -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);
index fa0604f796f19b117479cae6425ecacbf570b6c5..8bacc6e1a4c6266b1c6b566344d7afc9c38ba023 100644 (file)
@@ -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);
index 8aa8e0893667e6ca2a555e1c6c00f04fbad5c432..317f08ebeecf33db28ff0990f8c8e5d7bdd35557 100644 (file)
@@ -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);