Fix fieldfuncs test and track unused variables through writes as well.
authorDale Weiler <weilercdale@gmail.com>
Sat, 19 Nov 2016 12:19:00 +0000 (12:19 +0000)
committerDale Weiler <weilercdale@gmail.com>
Sat, 19 Nov 2016 12:19:00 +0000 (12:19 +0000)
ir.cpp
tests/fieldfuncs.tmpl

diff --git a/ir.cpp b/ir.cpp
index 7ac8477..51aab91 100644 (file)
--- 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());
index 1199b9b..04e0b8d 100644 (file)
@@ -1,6 +1,6 @@
 I: fieldfuncs.qc
 D: test fields with functions
-T: -compile
+T: -execute
 C: -std=fte
 M: 42
 M: 42