bug fixes after test-suite
authoreck <none@none>
Thu, 29 Mar 1990 10:41:46 +0000 (10:41 +0000)
committereck <none@none>
Thu, 29 Mar 1990 10:41:46 +0000 (10:41 +0000)
lang/cem/cemcom.ansi/arith.c
lang/cem/cemcom.ansi/ch3.c
lang/cem/cemcom.ansi/domacro.c
lang/cem/cemcom.ansi/eval.c
lang/cem/cemcom.ansi/field.c

index eacc7d9..5f9aa60 100644 (file)
@@ -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
 
index 1b2b844..24d7f71 100644 (file)
@@ -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;
        }
index 591a1ca..8561bae 100644 (file)
@@ -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 */
index 4b0c94f..e51ff91 100644 (file)
@@ -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) {
index ac7a932..15a7821 100644 (file)
@@ -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 */