]> git.xonotic.org Git - xonotic/gmqcc.git/blobdiff - ir.cpp
Remove parser m_uses in favor of {IR,AST}_FLAG_NOREF instead
[xonotic/gmqcc.git] / ir.cpp
diff --git a/ir.cpp b/ir.cpp
index d6a54932473b0e5df5f163ed4b8c82d6b457cbcd..3b78c35a7096a81fd7daa240df505f4890dc0ee1 100644 (file)
--- a/ir.cpp
+++ b/ir.cpp
@@ -633,7 +633,7 @@ bool ir_function_finalize(ir_function *self)
 
     for (auto& lp : self->m_locals) {
         ir_value *v = lp.get();
-        if (v->m_reads.empty() && v->m_writes.size()) {
+        if (v->m_reads.empty() && v->m_writes.size() && !(v->m_flags & IR_FLAG_NOREF)) {
             // if it's a vector check to ensure all it's members are unused before
             // claiming it's unused, otherwise skip the vector entierly
             if (v->m_vtype == TYPE_VECTOR)
@@ -651,13 +651,14 @@ bool ir_function_finalize(ir_function *self)
                     // individual components are unused so mention them
                     for (size_t i = 0; i < 3; i++)
                         if ((bits & (1 << i))
-                            && irwarning(v->m_context, WARN_UNUSED_VARIABLE,
-                                "unused variable: `%s.%c`", v->m_name.c_str(), "xyz"[i]))
+                            && irwarning(v->m_context, WARN_UNUSED_COMPONENT,
+                                "unused vector component: `%s.%c`", v->m_name.c_str(), "xyz"[i]))
                             return false;
             }
             // just a standard variable
-            else if (irwarning(v->m_context, WARN_UNUSED_VARIABLE,
-                "unused variable: `%s`", v->m_name.c_str())) return false;
+            else if (v->m_name[0] != '#'
+                && irwarning(v->m_context, WARN_UNUSED_VARIABLE,
+                    "unused variable: `%s`", v->m_name.c_str())) return false;
         }
     }