mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-26 06:10:56 +00:00
o don't ice when ex_name or ex_nil expressions show up in emit_expr.
instead, treat as useless epxression. o mark rvalue expressions as such o increment the users of a managed temp def when in an rvalue expr
This commit is contained in:
parent
0c511d3da5
commit
80723fdec7
5 changed files with 17 additions and 9 deletions
|
@ -86,7 +86,8 @@ typedef struct expr_s {
|
|||
expr_type type;
|
||||
int line;
|
||||
string_t file;
|
||||
int paren;
|
||||
unsigned paren:1;
|
||||
unsigned rvalue:1;
|
||||
union {
|
||||
elabel_t label;
|
||||
block_t block;
|
||||
|
|
|
@ -206,6 +206,8 @@ emit_assign_expr (int oper, expr_t *e)
|
|||
return def_a;
|
||||
} else {
|
||||
def_b = emit_sub_expr (e2, 0);
|
||||
if (e->rvalue && def_b->managed)
|
||||
def_b->users++;
|
||||
if (e1->type == ex_expr && extract_type (e1->e.expr.e1) == ev_pointer) {
|
||||
def_a = emit_sub_expr (e1->e.expr.e1, 0);
|
||||
def_c = emit_sub_expr (e1->e.expr.e2, 0);
|
||||
|
@ -420,6 +422,9 @@ emit_expr (expr_t *e)
|
|||
statref_t *ref;
|
||||
elabel_t *label;
|
||||
|
||||
//printf ("%d ", e->line);
|
||||
//print_expr (e);
|
||||
//puts ("");
|
||||
switch (e->type) {
|
||||
case ex_label:
|
||||
label = &e->e.label;
|
||||
|
@ -522,12 +527,10 @@ emit_expr (expr_t *e)
|
|||
case ex_integer:
|
||||
case ex_uinteger:
|
||||
case ex_short:
|
||||
case ex_name:
|
||||
case ex_nil:
|
||||
warning (e, "Ignoring useless expression");
|
||||
break;
|
||||
case ex_nil:
|
||||
case ex_name:
|
||||
error (e, "internal error");
|
||||
abort ();
|
||||
}
|
||||
PR_FreeTempDefs ();
|
||||
}
|
||||
|
|
|
@ -1748,6 +1748,8 @@ assign_expr (expr_t *e1, expr_t *e2)
|
|||
convert_nil (e2, t2);
|
||||
}
|
||||
|
||||
e2->rvalue = 1;
|
||||
|
||||
if (t1 != t2) {
|
||||
if (!options.traditional || t1->type != ev_func || t2->type != ev_func)
|
||||
return type_mismatch (e1, e2, op);
|
||||
|
|
|
@ -321,8 +321,9 @@ PR_FreeTempDefs (void)
|
|||
*def = d->next;
|
||||
|
||||
if (d->users < 0)
|
||||
printf ("%s:%d: warning: %s %3d %3d\n", strings + d->file,
|
||||
d->line, pr_type_name[d->type->type], d->ofs, d->users);
|
||||
printf ("%s:%d: warning: %s %3d %3d %d\n", strings + d->file,
|
||||
d->line, pr_type_name[d->type->type], d->ofs, d->users,
|
||||
d->managed);
|
||||
size = pr_type_size[d->type->type];
|
||||
if (d->expr)
|
||||
d->expr->e.temp.def = 0;
|
||||
|
@ -349,8 +350,8 @@ PR_ResetTempDefs (void)
|
|||
}
|
||||
|
||||
for (d = temp_scope.next; d; d = d->next)
|
||||
printf ("%s:%d: warning: %s %3d %3d\n", strings + d->file, d->line,
|
||||
pr_type_name[d->type->type], d->ofs, d->users);
|
||||
printf ("%s:%d: warning: %s %3d %3d %d\n", strings + d->file, d->line,
|
||||
pr_type_name[d->type->type], d->ofs, d->users, d->managed);
|
||||
temp_scope.next = 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -1007,6 +1007,7 @@ emit_function (function_t *f, expr_t *e)
|
|||
|
||||
pr_scope = f->def;
|
||||
while (e) {
|
||||
//printf ("%d ", pr_source_line);
|
||||
//print_expr (e);
|
||||
//puts("");
|
||||
|
||||
|
|
Loading…
Reference in a new issue