]> git.rm.cloudns.org Git - xonotic/gmqcc.git/commitdiff
-Wvoid-variables, QC uses 2 special void-typed variables: end_sys_globals and .end_sy...
authorWolfgang (Blub) Bumiller <blub@speed.at>
Tue, 21 Aug 2012 13:49:53 +0000 (15:49 +0200)
committerWolfgang (Blub) Bumiller <blub@speed.at>
Tue, 21 Aug 2012 13:49:53 +0000 (15:49 +0200)
ir.c
main.c
warns.def

diff --git a/ir.c b/ir.c
index acdaa225264c90b0096799ec239a1343499e680f..2261e884e8ca3db375438b717b04030aa3b612a6 100644 (file)
--- a/ir.c
+++ b/ir.c
@@ -2632,6 +2632,28 @@ static bool ir_builder_gen_global(ir_builder *self, ir_value *global)
 
     switch (global->vtype)
     {
+    case TYPE_VOID:
+        if (!strcmp(global->name, "end_sys_globals")) {
+            /* TODO: remember this point... all the defs before this one
+             * should be checksummed and added to progdefs.h when we generate it.
+             */
+        }
+        else if (!strcmp(global->name, "end_sys_globals")) {
+            /* TODO: same as above but for entity-fields rather than globsl
+             */
+        }
+        else
+            irwarning(global->context, WARN_VOID_VARIABLES, "unrecognized variable of type void `%s`",
+                      global->name);
+        /* I'd argue setting it to 0 is sufficient, but maybe some depend on knowing how far
+         * the system fields actually go? Though the engine knows this anyway...
+         * Maybe this could be an -foption
+         */
+        ir_value_code_setaddr(global, def.offset);
+        /* Add the def */
+        if (code_defs_add(def) < 0)
+            return false;
+        return true;
     case TYPE_POINTER:
         if (code_defs_add(def) < 0)
             return false;
diff --git a/main.c b/main.c
index d8d1c2e9256d3daad45d431fe9e8bf59c5a8410c..2aeef3ba57006117b999612a28784c497f06a205 100644 (file)
--- a/main.c
+++ b/main.c
@@ -385,6 +385,7 @@ int main(int argc, char **argv) {
     options_set(opts_warn, WARN_MISSING_RETURN_VALUES, true);
     options_set(opts_warn, WARN_USED_UNINITIALIZED, true);
     options_set(opts_warn, WARN_LOCAL_CONSTANTS, true);
+    options_set(opts_warn, WARN_VOID_VARIABLE, true);
 
     if (!options_parse(argc, argv)) {
         return usage();
index 92a2f2b7e402b081471351762f6771e21a5eab52..b8609a6d78ef82bbafed76b935e9173f7e90ee07 100644 (file)
--- a/warns.def
+++ b/warns.def
@@ -12,3 +12,4 @@ GMQCC_DEFINE_FLAG(MISSING_RETURN_VALUES)
 GMQCC_DEFINE_FLAG(TOO_FEW_PARAMETERS)
 GMQCC_DEFINE_FLAG(LOCAL_SHADOWS)
 GMQCC_DEFINE_FLAG(LOCAL_CONSTANTS)
+GMQCC_DEFINE_FLAG(VOID_VARIABLES)