]> git.xonotic.org Git - xonotic/gmqcc.git/commitdiff
conversion warnings and sanity check
authorWolfgang (Blub) Bumiller <blub@speed.at>
Thu, 22 Nov 2012 20:25:02 +0000 (21:25 +0100)
committerWolfgang (Blub) Bumiller <blub@speed.at>
Thu, 22 Nov 2012 20:25:02 +0000 (21:25 +0100)
ir.c

diff --git a/ir.c b/ir.c
index 70004b87bd87b38c1d045af05f9f3bad4414048f..a8d54f07437601a5559c0c2ece87d1d144a733b7 100644 (file)
--- a/ir.c
+++ b/ir.c
@@ -3045,8 +3045,8 @@ static bool ir_builder_gen_field(ir_builder *self, ir_value *field)
     prog_section_def def;
     prog_section_field fld;
 
-    def.type   = field->vtype;
-    def.offset = vec_size(code_globals);
+    def.type   = (uint16_t)field->vtype;
+    def.offset = (uint16_t)vec_size(code_globals);
 
     /* create a global named the same as the field */
     if (opts_standard == COMPILER_GMQCC) {
@@ -3134,6 +3134,11 @@ bool ir_builder_generate(ir_builder *self, const char *filename)
         }
     }
 
+    if (vec_size(code_globals) >= 65536) {
+        irerror(vec_last(self->globals)->context, "This progs file would require more globals than the metadata can handle. Bailing out.");
+        return false;
+    }
+
     /* DP errors if the last instruction is not an INSTR_DONE
      * and for debugging purposes we add an additional AINSTR_END
      * to the end of functions, so here it goes: