mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2025-03-22 02:11:19 +00:00
really warn only once for each uninitialized variable
This commit is contained in:
parent
e7f478b197
commit
04765083aa
2 changed files with 3 additions and 2 deletions
|
@ -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
|
||||
|
|
|
@ -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 ());
|
||||
|
|
Loading…
Reference in a new issue