Help with bit-field semantics in C and C++
Gabriel Dos Reis
gdr@integrable-solutions.net
Wed Aug 25 00:38:00 GMT 2004
Richard Henderson <rth@redhat.com> writes:
[...]
| I wonder if a better representation would be subrange types,
| as seen in Ada. This case has characteristics:
|
| TREE_CODE (enum_type) == INTEGER_TYPE
| TREE_TYPE (enum_type) == compatible_int_type
| TYPE_MODE (enum_type) == TYPE_MODE (compatible_int_type)
| TYPE_PRECISION (enum_type) == TYPE_PRECISION (compatible_int_type)
| TYPE_MIN_VALUE (enum_type) == subrange start value
| TYPE_MAX_VALUE (enum_type) == subrange end value
|
| The precision and mode are set such that we see that mask
| operations are not required, but min and max are set to a
| reduced range so that we can see that we're dealing with a
| constrained set of values.
That is a much improved representation. The question still remains as
what we do when we switch on enum values. Am I correctly
understanding you that TYPE_MIN_VALUE and TYPE_MAX_VALUE would be used
as guards when generating jump tables? Those should not be needed
because enums have values in range.
-- Gaby
More information about the Gcc
mailing list