More on type sizes

Joern Rennecke amylaar@cygnus.co.uk
Fri Dec 31 23:54:00 GMT 1999


>     P.S.: Chill uses bit arrays. For these, the elements have a TYPE_SIZE
>     (of one), but no TYPE_SIZE_UNIT.  
> 
> What code handles these?  Other languages (such as Ada) could benefit from
> that, and I'd like to support it fully sometime, but what code handles it?

I just spotted this bit in stor-layout.c:layout_type :

            /* Special handling for arrays of bits (for Chill).  */
            element_size = TYPE_SIZE (element);
            if (TYPE_PACKED (type) && INTEGRAL_TYPE_P (element))
              {
                HOST_WIDE_INT maxvalue
                  = TREE_INT_CST_LOW (TYPE_MAX_VALUE (element));
                HOST_WIDE_INT minvalue
                  = TREE_INT_CST_LOW (TYPE_MIN_VALUE (element));

                if (maxvalue - minvalue == 1
                    && (maxvalue == 1 || maxvalue == 0))
                  element_size = integer_one_node;
              }

>     Incidentally, the TYPE_SIZE of these elements is integer_size_node,
>     which is still wrong, since it has integer_type_node as type - this
>     should be converted to bitsizetype.
> 
> Yes, that's certainly wrong.  How did it happen?  Does the front end set
> TYPE_SIZE?  That almost always sounds wrong to me: only layout_type
> should be setting it.

layout_type does, see above.



More information about the Gcc mailing list