diff --git a/tools/qfcc/source/expr.c b/tools/qfcc/source/expr.c index eb8bd7784..266d65cec 100644 --- a/tools/qfcc/source/expr.c +++ b/tools/qfcc/source/expr.c @@ -1233,6 +1233,8 @@ emit_sub_expr (expr_t *e, def_t *dest) } else { abort (); } + if (!dest) + dest = PR_GetTempDef (e->e.expr.type, pr_scope); op = PR_Opcode_Find (operator, priority, def_a, def_b, dest); return emit_statement (e->line, op, def_a, def_b, dest); case ex_def: diff --git a/tools/qfcc/source/qc-parse.y b/tools/qfcc/source/qc-parse.y index 908c7cade..9b318c798 100644 --- a/tools/qfcc/source/qc-parse.y +++ b/tools/qfcc/source/qc-parse.y @@ -427,26 +427,26 @@ statement ; expr - : expr '=' expr { $$ = binary_expr ('=', $1, $3); } - | expr AND expr { $$ = binary_expr (AND, $1, $3); } - | expr OR expr { $$ = binary_expr (OR, $1, $3); } - | expr EQ expr { $$ = binary_expr (EQ, $1, $3); } - | expr NE expr { $$ = binary_expr (NE, $1, $3); } - | expr LE expr { $$ = binary_expr (LE, $1, $3); } - | expr GE expr { $$ = binary_expr (GE, $1, $3); } - | expr LT expr { $$ = binary_expr (LT, $1, $3); } - | expr GT expr { $$ = binary_expr (GT, $1, $3); } - | expr '+' expr { $$ = binary_expr ('+', $1, $3); } - | expr '-' expr { $$ = binary_expr ('-', $1, $3); } - | expr '*' expr { $$ = binary_expr ('*', $1, $3); } - | expr '/' expr { $$ = binary_expr ('/', $1, $3); } - | expr '&' expr { $$ = binary_expr ('&', $1, $3); } - | expr '|' expr { $$ = binary_expr ('|', $1, $3); } + : expr '=' expr { $$ = binary_expr ('=', $1, $3); } + | expr AND expr { $$ = binary_expr (AND, $1, $3); } + | expr OR expr { $$ = binary_expr (OR, $1, $3); } + | expr EQ expr { $$ = binary_expr (EQ, $1, $3); } + | expr NE expr { $$ = binary_expr (NE, $1, $3); } + | expr LE expr { $$ = binary_expr (LE, $1, $3); } + | expr GE expr { $$ = binary_expr (GE, $1, $3); } + | expr LT expr { $$ = binary_expr (LT, $1, $3); } + | expr GT expr { $$ = binary_expr (GT, $1, $3); } + | expr '+' expr { $$ = binary_expr ('+', $1, $3); } + | expr '-' expr { $$ = binary_expr ('-', $1, $3); } + | expr '*' expr { $$ = binary_expr ('*', $1, $3); } + | expr '/' expr { $$ = binary_expr ('/', $1, $3); } + | expr '&' expr { $$ = binary_expr ('&', $1, $3); } + | expr '|' expr { $$ = binary_expr ('|', $1, $3); } | expr '(' arg_list ')' { $$ = function_expr ($1, $3); } | expr '(' ')' { $$ = function_expr ($1, 0); } - | expr '.' expr { $$ = binary_expr ('.', $1, $3); } - | '-' expr { $$ = unary_expr ('-', $2); } - | '!' expr { $$ = unary_expr ('!', $2); } + | expr '.' expr { $$ = binary_expr ('.', $1, $3); } + | '-' expr %prec '!' { $$ = unary_expr ('-', $2); } + | '!' expr { $$ = unary_expr ('!', $2); } | NAME { $$ = new_expr ();