Fix fieldfuncs test and track unused variables through writes as well.

This commit is contained in:
Dale Weiler 2016-11-19 12:19:00 +00:00
parent 6938567c6c
commit 9821b6a075
2 changed files with 8 additions and 1 deletions

7
ir.cpp
View file

@ -631,6 +631,13 @@ bool ir_function_finalize(ir_function *self)
if (self->m_builtin)
return true;
for (auto& lp : self->m_locals) {
ir_value *v = lp.get();
if (v->m_reads.empty() && v->m_writes.size()
&& irwarning(v->m_context, WARN_UNUSED_VARIABLE,
"unused variable: `%s`", v->m_name.c_str())) return false;
}
if (OPTS_OPTIMIZATION(OPTIM_PEEPHOLE)) {
if (!ir_function_pass_peephole(self)) {
irerror(self->m_context, "generic optimization pass broke something in `%s`", self->m_name.c_str());

View file

@ -1,6 +1,6 @@
I: fieldfuncs.qc
D: test fields with functions
T: -compile
T: -execute
C: -std=fte
M: 42
M: 42