From 6b575372ccc87fd26bdaf233849a5b61fd634bb3 Mon Sep 17 00:00:00 2001 From: "Wolfgang (Blub) Bumiller" Date: Sun, 2 Dec 2012 18:09:59 +0100 Subject: [PATCH] Don't warn about uninitialized stuff in accessors - remove the liferanges calculated when finalizing accessors, this would add invalid liferanges to function-local arrays and thus suppress warnings randomly --- ast.c | 9 +++++++++ gmqcc.h | 2 ++ main.c | 2 +- 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/ast.c b/ast.c index f388eb3..31df700 100644 --- a/ast.c +++ b/ast.c @@ -1403,6 +1403,7 @@ error: /* clean up */ bool ast_generate_accessors(ast_value *self, ir_builder *ir) { size_t i; + bool warn = OPTS_WARN(WARN_USED_UNINITIALIZED); if (!self->setter || !self->getter) return true; for (i = 0; i < self->expression.count; ++i) { @@ -1419,12 +1420,15 @@ bool ast_generate_accessors(ast_value *self, ir_builder *ir) return false; } } + + options_set(opts_warn, WARN_USED_UNINITIALIZED, false); if (self->setter) { if (!ast_global_codegen (self->setter, ir, false) || !ast_function_codegen(self->setter->constval.vfunc, ir) || !ir_function_finalize(self->setter->constval.vfunc->ir_func)) { compile_error(ast_ctx(self), "internal error: failed to generate setter for `%s`", self->name); + options_set(opts_warn, WARN_USED_UNINITIALIZED, warn); return false; } } @@ -1434,9 +1438,14 @@ bool ast_generate_accessors(ast_value *self, ir_builder *ir) !ir_function_finalize(self->getter->constval.vfunc->ir_func)) { compile_error(ast_ctx(self), "internal error: failed to generate getter for `%s`", self->name); + options_set(opts_warn, WARN_USED_UNINITIALIZED, warn); return false; } } + for (i = 0; i < self->expression.count; ++i) { + vec_free(self->ir_values[i]->life); + } + options_set(opts_warn, WARN_USED_UNINITIALIZED, warn); return true; } diff --git a/gmqcc.h b/gmqcc.h index 2253c9e..c7d034e 100644 --- a/gmqcc.h +++ b/gmqcc.h @@ -946,4 +946,6 @@ extern uint32_t opts_flags [1 + (COUNT_FLAGS / 32)]; extern uint32_t opts_warn [1 + (COUNT_WARNINGS / 32)]; extern uint32_t opts_optimization[1 + (COUNT_OPTIMIZATIONS / 32)]; +void options_set(uint32_t *flags, size_t idx, bool on); + #endif diff --git a/main.c b/main.c index 220a2e3..4e4aa33 100644 --- a/main.c +++ b/main.c @@ -169,7 +169,7 @@ static bool options_long_gcc(const char *optname, int *argc_, char ***argv_, cha return options_long_witharg_all(optname, argc_, argv_, out, 1, false); } -static void options_set(uint32_t *flags, size_t idx, bool on) +void options_set(uint32_t *flags, size_t idx, bool on) { longbit lb = LONGBIT(idx); #if 0 -- 2.39.2