make the uninitialized warning depend on the -wuninitialized switch
authorMatthias Braun <matze@braunis.de>
Thu, 3 Mar 2011 15:54:57 +0000 (15:54 +0000)
committerMatthias Braun <matze@braunis.de>
Thu, 3 Mar 2011 15:54:57 +0000 (15:54 +0000)
[r28472]

ast2firm.c
warning.c
warning.h

index 3b5f53b..ccb3ebc 100644 (file)
@@ -133,7 +133,7 @@ static ir_node *uninitialized_local_var(ir_graph *irg, ir_mode *mode, int pos)
 {
        const entity_t *entity = get_irg_loc_description(irg, pos);
 
-       if (entity != NULL) {
+       if (entity != NULL && warning.uninitialized) {
                warningf(&entity->base.source_position,
                         "%s '%#T' might be used uninitialized",
                         get_entity_kind_name(entity->kind),
index f2fd2b9..34062c8 100644 (file)
--- a/warning.c
+++ b/warning.c
@@ -64,6 +64,7 @@ warning_t warning = {
        .switch_default                      = false,
        .switch_enum                         = false,
        .traditional                         = false,
+       .uninitialized                       = true,
        .unknown_pragmas                     = true,
        .unreachable_code                    = false,
        .unused_function                     = false,
@@ -113,6 +114,7 @@ void set_warning_opt(const char *const opt)
                SET(sign_compare);
                SET(strict_prototypes);
                SET(switch_enum);
+               SET(uninitialized);
                SET(unknown_pragmas);
                SET(unreachable_code);
                SET(unused_function);
@@ -178,6 +180,7 @@ void set_warning_opt(const char *const opt)
        OPT("switch-default",                      switch_default);
        OPT("switch-enum",                         switch_enum);
        OPT("traditional",                         traditional);
+       OPT("uninitialized",                       uninitialized);
        OPT("unknown-pragmas",                     unknown_pragmas);
        OPT("unreachable-code",                    unreachable_code);
        OPTX("unused") {
index ea1399e..42ea5db 100644 (file)
--- a/warning.h
+++ b/warning.h
@@ -99,8 +99,8 @@ typedef struct warning_t {
        bool traditional:1;                         /**< Warn about certain constructs that behave differently in traditional and ISO C */
 #if 0 // TODO
        bool undef:1;                               /**< Warn if an undefined identifier is evaluated in an '#if' directive */
-       bool uninitialized:1;                       /**< Warn if an automatic variable is used without being initialized or if a variable may be clobbered by a 'setjmp' call. */
 #endif
+       bool uninitialized:1;                       /**< Warn if an automatic variable is used without being initialized or if a variable may be clobbered by a 'setjmp' call. */
        bool unknown_pragmas:1;                     /**< Warn when a #pragma directive is encountered which is not understood */
        bool unreachable_code:1;                    /**< Warn if the compiler detects that code will never be executed */
        bool unused_function:1;                     /**< Warn whenever a static function is declared but not defined or a non-inline static function is unused */