mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-29 23:52:22 +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;
|
expr_type type;
|
||||||
int line;
|
int line;
|
||||||
string_t file;
|
string_t file;
|
||||||
int paren;
|
unsigned paren:1;
|
||||||
|
unsigned rvalue:1;
|
||||||
union {
|
union {
|
||||||
elabel_t label;
|
elabel_t label;
|
||||||
block_t block;
|
block_t block;
|
||||||
|
|
|
@ -206,6 +206,8 @@ emit_assign_expr (int oper, expr_t *e)
|
||||||
return def_a;
|
return def_a;
|
||||||
} else {
|
} else {
|
||||||
def_b = emit_sub_expr (e2, 0);
|
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) {
|
if (e1->type == ex_expr && extract_type (e1->e.expr.e1) == ev_pointer) {
|
||||||
def_a = emit_sub_expr (e1->e.expr.e1, 0);
|
def_a = emit_sub_expr (e1->e.expr.e1, 0);
|
||||||
def_c = emit_sub_expr (e1->e.expr.e2, 0);
|
def_c = emit_sub_expr (e1->e.expr.e2, 0);
|
||||||
|
@ -420,6 +422,9 @@ emit_expr (expr_t *e)
|
||||||
statref_t *ref;
|
statref_t *ref;
|
||||||
elabel_t *label;
|
elabel_t *label;
|
||||||
|
|
||||||
|
//printf ("%d ", e->line);
|
||||||
|
//print_expr (e);
|
||||||
|
//puts ("");
|
||||||
switch (e->type) {
|
switch (e->type) {
|
||||||
case ex_label:
|
case ex_label:
|
||||||
label = &e->e.label;
|
label = &e->e.label;
|
||||||
|
@ -522,12 +527,10 @@ emit_expr (expr_t *e)
|
||||||
case ex_integer:
|
case ex_integer:
|
||||||
case ex_uinteger:
|
case ex_uinteger:
|
||||||
case ex_short:
|
case ex_short:
|
||||||
|
case ex_name:
|
||||||
|
case ex_nil:
|
||||||
warning (e, "Ignoring useless expression");
|
warning (e, "Ignoring useless expression");
|
||||||
break;
|
break;
|
||||||
case ex_nil:
|
|
||||||
case ex_name:
|
|
||||||
error (e, "internal error");
|
|
||||||
abort ();
|
|
||||||
}
|
}
|
||||||
PR_FreeTempDefs ();
|
PR_FreeTempDefs ();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1748,6 +1748,8 @@ assign_expr (expr_t *e1, expr_t *e2)
|
||||||
convert_nil (e2, t2);
|
convert_nil (e2, t2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
e2->rvalue = 1;
|
||||||
|
|
||||||
if (t1 != t2) {
|
if (t1 != t2) {
|
||||||
if (!options.traditional || t1->type != ev_func || t2->type != ev_func)
|
if (!options.traditional || t1->type != ev_func || t2->type != ev_func)
|
||||||
return type_mismatch (e1, e2, op);
|
return type_mismatch (e1, e2, op);
|
||||||
|
|
|
@ -321,8 +321,9 @@ PR_FreeTempDefs (void)
|
||||||
*def = d->next;
|
*def = d->next;
|
||||||
|
|
||||||
if (d->users < 0)
|
if (d->users < 0)
|
||||||
printf ("%s:%d: warning: %s %3d %3d\n", strings + d->file,
|
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->line, pr_type_name[d->type->type], d->ofs, d->users,
|
||||||
|
d->managed);
|
||||||
size = pr_type_size[d->type->type];
|
size = pr_type_size[d->type->type];
|
||||||
if (d->expr)
|
if (d->expr)
|
||||||
d->expr->e.temp.def = 0;
|
d->expr->e.temp.def = 0;
|
||||||
|
@ -349,8 +350,8 @@ PR_ResetTempDefs (void)
|
||||||
}
|
}
|
||||||
|
|
||||||
for (d = temp_scope.next; d; d = d->next)
|
for (d = temp_scope.next; d; d = d->next)
|
||||||
printf ("%s:%d: warning: %s %3d %3d\n", strings + d->file, d->line,
|
printf ("%s:%d: warning: %s %3d %3d %d\n", strings + d->file, d->line,
|
||||||
pr_type_name[d->type->type], d->ofs, d->users);
|
pr_type_name[d->type->type], d->ofs, d->users, d->managed);
|
||||||
temp_scope.next = 0;
|
temp_scope.next = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1007,6 +1007,7 @@ emit_function (function_t *f, expr_t *e)
|
||||||
|
|
||||||
pr_scope = f->def;
|
pr_scope = f->def;
|
||||||
while (e) {
|
while (e) {
|
||||||
|
//printf ("%d ", pr_source_line);
|
||||||
//print_expr (e);
|
//print_expr (e);
|
||||||
//puts("");
|
//puts("");
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue