From 452728126d9148564ee212729dc67dbeeac0e793 Mon Sep 17 00:00:00 2001 From: Bill Currie Date: Fri, 21 Dec 2012 17:12:41 +0900 Subject: [PATCH] Check the expression type when casting constants. Not all constant expressions are ex_value. This fixes the bogus errors and ice in paroxysm. --- tools/qfcc/source/expr.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/tools/qfcc/source/expr.c b/tools/qfcc/source/expr.c index 70c659c79..94fc73360 100644 --- a/tools/qfcc/source/expr.c +++ b/tools/qfcc/source/expr.c @@ -2677,7 +2677,19 @@ cast_expr (type_t *type, expr_t *e) if (is_array (e_type)) return address_expr (e, 0, 0); if (is_constant (e) && is_scalar (type) && is_scalar (e_type)) { - e->e.value = convert_value (e->e.value, type); + ex_value_t *val = 0; + if (e->type == ex_symbol && e->e.symbol->sy_type == sy_const) { + val = e->e.symbol->s.value; + } else if (e->type == ex_value) { + val = e->e.value; + } else if (e->type == ex_nil) { + convert_nil (e, type); + return e; + } + if (!val) + internal_error (e, "unexpected constant expression type"); + e->e.value = convert_value (val, type); + e->type = ex_value; c = e; } else if ((is_float (type) && is_integral (e_type)) || (is_integral (type) && is_float (e_type))) {