really warn only once for each uninitialized variable

This commit is contained in:
Bill Currie 2007-04-06 08:56:37 +00:00 committed by Jeff Teunissen
parent e7f478b197
commit 04765083aa
2 changed files with 3 additions and 2 deletions

View file

@ -43,6 +43,7 @@ typedef struct def_s {
struct reloc_s *refs; // for relocations
unsigned initialized:1; // for uninit var detection
unsigned suppress:1; // for uninit var detection suppression
unsigned set:1; // uninit var auto-inited
unsigned constant:1; // 1 when a declaration included "= immediate"
unsigned freed:1; // already freed from the scope

View file

@ -306,9 +306,9 @@ check_initialized (expr_t *e)
&& !e->e.def->external
&& !e->e.def->initialized) {
name = e->e.def->name;
if (options.warnings.uninited_variable)
if (options.warnings.uninited_variable && !e->e.def->suppress)
warning (e, "%s may be used uninitialized", name);
e->e.def->initialized = 1; // only warn once
e->e.def->suppress = 1; // only warn once
if (options.traditional && !e->e.def->set) {
e->e.def->set = 1; // only auto-init once
e = assign_expr (e, new_nil_expr ());