From: Dale Weiler Date: Sat, 19 Nov 2016 12:19:00 +0000 (+0000) Subject: Fix fieldfuncs test and track unused variables through writes as well. X-Git-Tag: xonotic-v0.8.5~55 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=9821b6a0753ffa490874203e59d1fb8ac6d11740;p=xonotic%2Fgmqcc.git Fix fieldfuncs test and track unused variables through writes as well. --- diff --git a/ir.cpp b/ir.cpp index 7ac8477..51aab91 100644 --- a/ir.cpp +++ b/ir.cpp @@ -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()); diff --git a/tests/fieldfuncs.tmpl b/tests/fieldfuncs.tmpl index 1199b9b..04e0b8d 100644 --- a/tests/fieldfuncs.tmpl +++ b/tests/fieldfuncs.tmpl @@ -1,6 +1,6 @@ I: fieldfuncs.qc D: test fields with functions -T: -compile +T: -execute C: -std=fte M: 42 M: 42