From: eck Date: Thu, 29 Mar 1990 10:41:46 +0000 (+0000) Subject: bug fixes after test-suite X-Git-Tag: release-5-5~1763 X-Git-Url: https://git.ndcode.org/public/gitweb.cgi?a=commitdiff_plain;h=ed2516a57a3de1da92e76af809afcfef4c5805f6;p=ack.git bug fixes after test-suite --- diff --git a/lang/cem/cemcom.ansi/arith.c b/lang/cem/cemcom.ansi/arith.c index eacc7d9ea..5f9aa60c5 100644 --- a/lang/cem/cemcom.ansi/arith.c +++ b/lang/cem/cemcom.ansi/arith.c @@ -562,11 +562,14 @@ field2arith(expp) */ register struct type *tp = (*expp)->ex_type->tp_up; 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; - 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, '&', intexpr(fd->fd_mask, INT)); } @@ -579,7 +582,6 @@ field2arith(expp) ); ch3bin(expp, RIGHT, intexpr(bits_in_type - fd->fd_width, INT)); } - ch3cast(expp, CAST, tp); /* restore its original type */ } #endif NOBITFIELD diff --git a/lang/cem/cemcom.ansi/ch3.c b/lang/cem/cemcom.ansi/ch3.c index 1b2b844e2..24d7f71fe 100644 --- a/lang/cem/cemcom.ansi/ch3.c +++ b/lang/cem/cemcom.ansi/ch3.c @@ -136,8 +136,14 @@ ch3sel(expp, oper, idf) } } else { /* oper == ARROW */ - exp = new_oper(sd->sd_type, - exp, oper, intexpr(sd->sd_offset, INT)); + if (is_ld_cst(exp)) { + 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_flags &= ~EX_ILVALUE; } diff --git a/lang/cem/cemcom.ansi/domacro.c b/lang/cem/cemcom.ansi/domacro.c index 591a1ca5f..8561bae03 100644 --- a/lang/cem/cemcom.ansi/domacro.c +++ b/lang/cem/cemcom.ansi/domacro.c @@ -764,7 +764,7 @@ do_line(l) int t = GetToken(&tk); static char *saved_name = (char *)0; - SkipToNewLine(); + if (t != EOI) SkipToNewLine(); LineNumber = l; /* the number of the next input line */ if (t == STRING) { /* is there a filespecifier? */ extern char *source; /* defined in main.c */ diff --git a/lang/cem/cemcom.ansi/eval.c b/lang/cem/cemcom.ansi/eval.c index 4b0c94ff3..e51ff91b1 100644 --- a/lang/cem/cemcom.ansi/eval.c +++ b/lang/cem/cemcom.ansi/eval.c @@ -76,8 +76,16 @@ EVAL(expr, val, code, true_label, false_label) switch (expr->ex_class) { case Value: /* just a simple value */ - if (gencode) - load_val(expr, val); + if (gencode) { + 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; case String: /* a string constant */ if (gencode) { diff --git a/lang/cem/cemcom.ansi/field.c b/lang/cem/cemcom.ansi/field.c index ac7a932b1..15a782165 100644 --- a/lang/cem/cemcom.ansi/field.c +++ b/lang/cem/cemcom.ansi/field.c @@ -52,7 +52,10 @@ eval_field(expr, code) register struct field *fd = leftop->ex_type->tp_field; struct type *tp = leftop->ex_type->tp_up; 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 */ ASSERT(atype->tp_size == word_size); /* make sure that C_loc() is legal */