fixed sizeof()
authoreck <none@none>
Wed, 13 Dec 1989 12:53:22 +0000 (12:53 +0000)
committereck <none@none>
Wed, 13 Dec 1989 12:53:22 +0000 (12:53 +0000)
lang/cem/cemcom.ansi/ch3mon.c
lang/cem/cemcom.ansi/expression.g

index be2692f..801b2f9 100644 (file)
@@ -16,6 +16,7 @@
 #include       "expr.h"
 #include       "idf.h"
 #include       "def.h"
+#include       "sizes.h"
 
 extern char options[];
 extern arith full_mask[/*MAXSIZE*/];   /* cstoper.c */
@@ -150,7 +151,7 @@ ch3mon(oper, expp)
                                   (arith)((*expp)->SG_LEN) :
                                   size_of_type((*expp)->ex_type,
                                       symbol2str((*expp)->ex_type->tp_fund))
-                              , ULONG);
+                              , (int_size == pointer_size ? UNSIGNED : ULONG));
                expr->ex_flags |= EX_SIZEOF;
                free_expression(*expp);
                *expp = expr;
index cc388bb..2771b4d 100644 (file)
@@ -16,6 +16,7 @@
 #include       "label.h"
 #include       "expr.h"
 #include       "code.h"
+#include       "sizes.h"
 
 extern struct expr *intexpr();
 int InSizeof = 0;      /* inside a sizeof- expression */
@@ -146,7 +147,8 @@ size_of(register struct expr **expp;)
        [%if (first_of_type_specifier(AHEAD) && AHEAD != IDENTIFIER)
                cast(&tp)
                {
-                       *expp = intexpr(size_of_type(tp, "type"), ULONG);
+                       *expp = intexpr(size_of_type(tp, "type"),
+                               (int_size == pointer_size ? UNSIGNED : ULONG));
                        (*expp)->ex_flags |= EX_SIZEOF;
                }
        |