]> git.rm.cloudns.org Git - xonotic/gmqcc.git/commitdiff
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 7ac84773830e0a148b19b1eca21268192e1fac4b..51aab91f1c184366182729026863d6e4c745c6ca 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 1199b9b53f9db1d7c9c67bee046bb43c31935f84..04e0b8dda1863512bf300d188a67e06cdb153235 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