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

This commit is contained in:
Wolfgang (Blub) Bumiller 2012-12-02 18:09:59 +01:00
parent c926c4cb59
commit 6b575372cc
3 changed files with 12 additions and 1 deletions

9
ast.c
View file

@ -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;
}

View file

@ -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

2
main.c
View file

@ -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