bug fixes after test-suite

This commit is contained in:
eck 1990-03-29 10:41:46 +00:00
parent fd80d596df
commit ed2516a57a
5 changed files with 28 additions and 9 deletions

View file

@ -562,11 +562,14 @@ field2arith(expp)
*/ */
register struct type *tp = (*expp)->ex_type->tp_up; register struct type *tp = (*expp)->ex_type->tp_up;
register struct field *fd = (*expp)->ex_type->tp_field; register struct field *fd = (*expp)->ex_type->tp_field;
register struct type *atype = tp->tp_unsigned ? uword_type : word_type; register struct type *atype = (tp->tp_unsigned
&& fd->fd_width >= 8 * word_size)
? uword_type
: word_type;
(*expp)->ex_type = atype; (*expp)->ex_type = atype;
if (atype->tp_unsigned) { /* don't worry about the sign bit */ if (tp->tp_unsigned) { /* don't worry about the sign bit */
ch3bin(expp, RIGHT, intexpr((arith)fd->fd_shift, INT)); ch3bin(expp, RIGHT, intexpr((arith)fd->fd_shift, INT));
ch3bin(expp, '&', intexpr(fd->fd_mask, INT)); ch3bin(expp, '&', intexpr(fd->fd_mask, INT));
} }
@ -579,7 +582,6 @@ field2arith(expp)
); );
ch3bin(expp, RIGHT, intexpr(bits_in_type - fd->fd_width, INT)); ch3bin(expp, RIGHT, intexpr(bits_in_type - fd->fd_width, INT));
} }
ch3cast(expp, CAST, tp); /* restore its original type */
} }
#endif NOBITFIELD #endif NOBITFIELD

View file

@ -136,8 +136,14 @@ ch3sel(expp, oper, idf)
} }
} }
else { /* oper == ARROW */ else { /* oper == ARROW */
exp = new_oper(sd->sd_type, if (is_ld_cst(exp)) {
exp, oper, intexpr(sd->sd_offset, INT)); exp->VL_VALUE += sd->sd_offset;
exp->ex_type = sd->sd_type;
}
else {
exp = new_oper(sd->sd_type,
exp, oper, intexpr(sd->sd_offset, INT));
}
exp->ex_lvalue = (sd->sd_type->tp_fund != ARRAY); exp->ex_lvalue = (sd->sd_type->tp_fund != ARRAY);
exp->ex_flags &= ~EX_ILVALUE; exp->ex_flags &= ~EX_ILVALUE;
} }

View file

@ -764,7 +764,7 @@ do_line(l)
int t = GetToken(&tk); int t = GetToken(&tk);
static char *saved_name = (char *)0; static char *saved_name = (char *)0;
SkipToNewLine(); if (t != EOI) SkipToNewLine();
LineNumber = l; /* the number of the next input line */ LineNumber = l; /* the number of the next input line */
if (t == STRING) { /* is there a filespecifier? */ if (t == STRING) { /* is there a filespecifier? */
extern char *source; /* defined in main.c */ extern char *source; /* defined in main.c */

View file

@ -76,8 +76,16 @@ EVAL(expr, val, code, true_label, false_label)
switch (expr->ex_class) { switch (expr->ex_class) {
case Value: /* just a simple value */ case Value: /* just a simple value */
if (gencode) if (gencode) {
load_val(expr, val); if (true_label) {
/* can only result from ','-expressions with
constant right-hand sides ???
*/
ASSERT(is_cp_cst(expr));
C_bra(expr->VL_VALUE == 0 ? false_label : true_label);
}
else load_val(expr, val);
}
break; break;
case String: /* a string constant */ case String: /* a string constant */
if (gencode) { if (gencode) {

View file

@ -52,7 +52,10 @@ eval_field(expr, code)
register struct field *fd = leftop->ex_type->tp_field; register struct field *fd = leftop->ex_type->tp_field;
struct type *tp = leftop->ex_type->tp_up; struct type *tp = leftop->ex_type->tp_up;
arith tmpvar = 0; arith tmpvar = 0;
struct type *atype = tp->tp_unsigned ? uword_type : word_type; struct type *atype = ( tp->tp_unsigned
&& fd->fd_width >= 8 * word_size)
? uword_type
: word_type;
/* First some assertions to be sure that the rest is legal */ /* First some assertions to be sure that the rest is legal */
ASSERT(atype->tp_size == word_size); /* make sure that C_loc() is legal */ ASSERT(atype->tp_size == word_size); /* make sure that C_loc() is legal */