diff --git a/tools/qfcc/include/expr.h b/tools/qfcc/include/expr.h index 8973f810b..5b1c6d1e7 100644 --- a/tools/qfcc/include/expr.h +++ b/tools/qfcc/include/expr.h @@ -516,6 +516,8 @@ int is_math_op (int op); */ int is_logic (int op); +int has_function_call (expr_t *e); + int is_string_val (expr_t *e); int is_float_val (expr_t *e); int is_vector_val (expr_t *e); diff --git a/tools/qfcc/source/expr.c b/tools/qfcc/source/expr.c index bc5ba5a6e..14ee4b528 100644 --- a/tools/qfcc/source/expr.c +++ b/tools/qfcc/source/expr.c @@ -1488,7 +1488,7 @@ is_logic (int op) return 0; } -static int +int has_function_call (expr_t *e) { switch (e->type) { diff --git a/tools/qfcc/source/expr_binary.c b/tools/qfcc/source/expr_binary.c index d9f6f43b0..2aa963b3a 100644 --- a/tools/qfcc/source/expr_binary.c +++ b/tools/qfcc/source/expr_binary.c @@ -726,6 +726,11 @@ binary_expr (int op, expr_t *e1, expr_t *e2) expr_type_t *expr_type; convert_name (e1); + if (e1->type == ex_block && e1->e.block.is_call + && has_function_call (e2) && e1->e.block.result) { + e = new_temp_def_expr (get_type (e1->e.block.result)); + e1 = assign_expr (e, e1); + } if (e1->type == ex_error) return e1;