]> de.git.xonotic.org Git - xonotic/gmqcc.git/commitdiff
error when using a type not usable as boolean in a condition, ie an if statement
authorWolfgang Bumiller <blub@speed.at>
Fri, 25 Jan 2013 18:17:42 +0000 (19:17 +0100)
committerWolfgang Bumiller <blub@speed.at>
Fri, 25 Jan 2013 18:19:23 +0000 (19:19 +0100)
parser.c

index 159c7a829565980e2123b6cab446085720ade786..ac6428a4c268ee21fd79eefce4463e1e8d02bb48 100644 (file)
--- a/parser.c
+++ b/parser.c
@@ -2205,6 +2205,12 @@ static ast_expression* process_condition(parser_t *parser, ast_expression *cond,
     ast_unary *unary;
     ast_expression *prev;
 
+    if (cond->expression.vtype == TYPE_VOID || cond->expression.vtype >= TYPE_VARIANT) {
+        char ty[1024];
+        ast_type_to_string(cond, ty, sizeof(ty));
+        compile_error(ast_ctx(cond), "invalid type for if() condition: %s", ty);
+    }
+
     if (OPTS_FLAG(FALSE_EMPTY_STRINGS) && cond->expression.vtype == TYPE_STRING)
     {
         prev = cond;