]> git.xonotic.org Git - xonotic/gmqcc.git/blobdiff - ast.c
Merge remote-tracking branch 'origin/pp-unary-numbers'
[xonotic/gmqcc.git] / ast.c
diff --git a/ast.c b/ast.c
index 7d4b93dd28aa1c4acf254cbbe035491644a4a83e..2b4a456ebb08e5e388d79bbe9a910d49c51d1a9e 100644 (file)
--- a/ast.c
+++ b/ast.c
@@ -724,9 +724,12 @@ ast_ternary* ast_ternary_new(lex_ctx ctx, ast_expression *cond, ast_expression *
 
 void ast_ternary_delete(ast_ternary *self)
 {
-    ast_unref(self->cond);
-    ast_unref(self->on_true);
-    ast_unref(self->on_false);
+    /* the if()s are only there because computed-gotos can set them
+     * to NULL
+     */
+    if (self->cond)     ast_unref(self->cond);
+    if (self->on_true)  ast_unref(self->on_true);
+    if (self->on_false) ast_unref(self->on_false);
     ast_expression_delete((ast_expression*)self);
     mem_d(self);
 }
@@ -831,6 +834,8 @@ ast_label* ast_label_new(lex_ctx ctx, const char *name, bool undefined)
     ast_instantiate(ast_label, ctx, ast_label_delete);
     ast_expression_init((ast_expression*)self, (ast_expression_codegen*)&ast_label_codegen);
 
+    self->expression.vtype = TYPE_NOEXPR;
+
     self->name      = util_strdup(name);
     self->irblock   = NULL;
     self->gotos     = NULL;