diff --git a/tools/qfcc/source/def.c b/tools/qfcc/source/def.c index 2b946a72c..f7735d8c3 100644 --- a/tools/qfcc/source/def.c +++ b/tools/qfcc/source/def.c @@ -585,8 +585,20 @@ initialize_def (symbol_t *sym, expr_t *init, defspace_t *space, // fold_constants takes care of int/float conversions append_expr (local_expr, fold_constants (init)); } else { + int offset = 0; + if (!is_constant (init)) { + error (init, "non-constant initializier"); + return; + } + while ((init->type == ex_uexpr || init->type == ex_expr) + && init->e.expr.op == 'A') { + if (init->type == ex_expr) { + offset += expr_integer (init->e.expr.e2); + } + init = init->e.expr.e1; + } if (init->type != ex_value) { //FIXME enum etc - error (0, "non-constant initializier"); + internal_error (0, "initializier not a value"); return; } if (init->e.value->lltype == ev_pointer diff --git a/tools/qfcc/source/expr.c b/tools/qfcc/source/expr.c index 842da5ad8..7d7e55a21 100644 --- a/tools/qfcc/source/expr.c +++ b/tools/qfcc/source/expr.c @@ -777,6 +777,10 @@ new_short_expr (short short_val) int is_constant (expr_t *e) { + while ((e->type == ex_uexpr || e->type == ex_expr) + && e->e.expr.op == 'A') { + e = e->e.expr.e1; + } if (e->type == ex_nil || e->type == ex_value || e->type == ex_labelref || (e->type == ex_symbol && e->e.symbol->sy_type == sy_const) || (e->type == ex_symbol && e->e.symbol->sy_type == sy_var