use C_con_cst instead of C_con_icon when possible;
authorceriel <none@none>
Mon, 12 Dec 1988 14:21:45 +0000 (14:21 +0000)
committerceriel <none@none>
Mon, 12 Dec 1988 14:21:45 +0000 (14:21 +0000)
fix sizeof(string) to return the size of the string instead of the size of
a pointer

lang/cem/cemcom/Makefile
lang/cem/cemcom/ch7mon.c
lang/cem/cemcom/ival.g

index f2762b4..8cd000f 100644 (file)
@@ -17,7 +17,7 @@ PRTLIB = $(EMHOME)/modules/lib/libprint.a
 EMMESLIB = $(EMHOME)/modules/lib/libem_mes.a
 EMMESOLIB = $(EMHOME)/modules/lib/libem_mesO.a
 EMMESCELIB = $(EMHOME)/modules/lib/libem_mesCE.a
-MACH = vax4
+MACH = sun3
 EMCELIB = $(EMHOME)/lib/$(MACH)/ce.a \
                $(EMHOME)/lib/$(MACH)/back.a \
                $(EMHOME)/modules/lib/libobject.a $(EMHOME)/lib/em_data.a
index dabefba..a5a3ad1 100644 (file)
@@ -153,7 +153,10 @@ ch7mon(oper, expp)
                )
                        warning("sizeof formal array %s is sizeof pointer!",
                                (*expp)->VL_IDF->id_text);
-               expr = intexpr(size_of_type((*expp)->ex_type, "object"), INT);
+               expr = intexpr((*expp)->ex_type == string_type ?
+                                  (arith)((*expp)->SG_LEN) :
+                                  size_of_type((*expp)->ex_type, "object"),
+                               INT);
                expr->ex_flags |= EX_SIZEOF;
                free_expression(*expp);
                *expp = expr;
index 3af7f14..3d78418 100644 (file)
@@ -674,6 +674,8 @@ con_int(ex)
        ASSERT(is_cp_cst(ex));
        if (tp->tp_unsigned)
                C_con_ucon(long2str((long)ex->VL_VALUE, -10), tp->tp_size);
+       else if (tp->tp_size == word_size)
+               C_con_cst(ex->VL_VALUE);
        else
                C_con_icon(long2str((long)ex->VL_VALUE, 10), tp->tp_size);
 }