From: Wolfgang Bumiller Date: Fri, 25 Jan 2013 18:17:42 +0000 (+0100) Subject: error when using a type not usable as boolean in a condition, ie an if statement X-Git-Tag: before-library~217 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=9afe41471bc37964bb933a8e246d8e5c676b2309;p=xonotic%2Fgmqcc.git error when using a type not usable as boolean in a condition, ie an if statement --- diff --git a/parser.c b/parser.c index 159c7a8..ac6428a 100644 --- 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;