__attribute__((const)) has rather nasty results when it's not true
expr.c:
	fix up some mis-timed ex_error checks
This commit is contained in:
Bill Currie 2002-05-02 05:03:57 +00:00
parent 05788e55e5
commit 54fb180fad
2 changed files with 11 additions and 15 deletions

View file

@ -119,8 +119,8 @@ extern etype_t qc_types[];
extern struct type_s *types[]; extern struct type_s *types[];
extern expr_type expr_types[]; extern expr_type expr_types[];
type_t *get_type (expr_t *e) __attribute__ ((const)); type_t *get_type (expr_t *e);
etype_t extract_type (expr_t *e) __attribute__ ((const)); etype_t extract_type (expr_t *e);
expr_t *new_expr (void); expr_t *new_expr (void);
const char *new_label_name (void); const char *new_label_name (void);

View file

@ -936,11 +936,6 @@ field_expr (expr_t *e1, expr_t *e2)
expr_t *e; expr_t *e;
struct_field_t *field; struct_field_t *field;
if (e1->type == ex_error)
return e1;
if (e2->type == ex_error)
return e2;
t1 = get_type (e1); t1 = get_type (e1);
switch (t1->type) { switch (t1->type) {
case ev_struct: case ev_struct:
@ -1444,8 +1439,11 @@ function_expr (expr_t *e1, expr_t *e2)
if (e1->type == ex_error) if (e1->type == ex_error)
return e1; return e1;
if (e2->type == ex_error) for (e = e2; e; e = e->next) {
return e2; if (e->type == ex_error)
return e;
parm_count++;
}
t1 = extract_type (e1); t1 = extract_type (e1);
@ -1473,8 +1471,6 @@ function_expr (expr_t *e1, expr_t *e2)
ftype = e1->type == ex_def ? e1->e.def->type : e1->e.expr.type; ftype = e1->type == ex_def ? e1->e.def->type : e1->e.expr.type;
for (e = e2; e; e = e->next)
parm_count++;
if (parm_count > MAX_PARMS) { if (parm_count > MAX_PARMS) {
return error (e1, "more than %d parameters", MAX_PARMS); return error (e1, "more than %d parameters", MAX_PARMS);
} }
@ -1558,8 +1554,6 @@ function_expr (expr_t *e1, expr_t *e2)
expr_t * expr_t *
return_expr (function_t *f, expr_t *e) return_expr (function_t *f, expr_t *e)
{ {
if (e->type == ex_error)
return e;
if (!e) { if (!e) {
if (f->def->type->aux_type != &type_void) { if (f->def->type->aux_type != &type_void) {
if (options.traditional) { if (options.traditional) {
@ -1575,6 +1569,8 @@ return_expr (function_t *f, expr_t *e)
if (e) { if (e) {
type_t *t = get_type (e); type_t *t = get_type (e);
if (e->type == ex_error)
return e;
if (f->def->type->aux_type == &type_void) if (f->def->type->aux_type == &type_void)
return error (e, "returning a value for a void function"); return error (e, "returning a value for a void function");
if (f->def->type->aux_type == &type_float && e->type == ex_integer) { if (f->def->type->aux_type == &type_float && e->type == ex_integer) {
@ -1699,8 +1695,6 @@ address_expr (expr_t *e1, expr_t *e2, type_t *t)
if (e1->type == ex_error) if (e1->type == ex_error)
return e1; return e1;
if (e2->type == ex_error)
return e2;
if (!t) if (!t)
t = get_type (e1); t = get_type (e1);
@ -1745,6 +1739,8 @@ address_expr (expr_t *e1, expr_t *e2, type_t *t)
return error (e1, "invalid type for unary &"); return error (e1, "invalid type for unary &");
} }
if (e2) { if (e2) {
if (e2->type == ex_error)
return e2;
if (e->type == ex_pointer && e2->type == ex_short) { if (e->type == ex_pointer && e2->type == ex_short) {
e->e.pointer.val += e2->e.short_val; e->e.pointer.val += e2->e.short_val;
} else { } else {