This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Help with bit-field semantics in C and C++
- From: Gabriel Dos Reis <gdr at integrable-solutions dot net>
- To: Richard Henderson <rth at redhat dot com>
- Cc: Mark Mitchell <mark at codesourcery dot com>, Mike Stump <mrs at apple dot com>, Dave Korn <dk at artimi dot com>, "'Roger Sayle'" <roger at eyesopen dot com>, "'Joe Buck'" <Joe dot Buck at synopsys dot com>, gcc at gcc dot gnu dot org
- Date: 25 Aug 2004 02:29:16 +0200
- Subject: Re: Help with bit-field semantics in C and C++
- Organization: Integrable Solutions
- References: <195B2A50-F60D-11D8-AF5A-003065BDF310@apple.com><412BAEF5.6010302@codesourcery.com><20040824234524.GA29526@redhat.com>
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