This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] strict types in code generators.
- From: Paul Schlie <schlie at comcast dot net>
- To: Zack Weinberg <zack at codesourcery dot com>
- Cc: Marcin Dalecki <martin at dalecki dot de>,Patch List <gcc-patches at gcc dot gnu dot org>
- Date: Wed, 02 Mar 2005 08:30:13 -0500
- Subject: Re: [PATCH] strict types in code generators.
> From: Zack Weinberg <zack@codesourcery.com>
> Date: Tue, 01 Mar 2005 22:36:39 -0800
> To: Paul Schlie <schlie@comcast.net>
> Cc: Marcin Dalecki <martin@dalecki.de>, Patch List <gcc-patches@gcc.gnu.org>
> Subject: Re: [PATCH] strict types in code generators.
>
> Paul Schlie <schlie@comcast.net> writes:
>
>>> Zack Weinberg wrote:
>>>> Marcin Dalecki wrote:
>>>> * genmodes.c, machmode.h: Use the proper enum mode_class type
>>>> instead of the "opaque" unsigned char, since this is what the
>>>> objects in question are really used for.
>>>
>>> Not OK. This will quadruple the size of the arrays in question.
>>
>> - Might this be acceptable if the correspondingly generated insn-modes.h
>> was itself defined to be #include'ed in the beginning of this generated
>> file?
>
> Nope. That doesn't generally change the size of a variable declared
> with enumeration type. (Yes, there is -fshort-enums, but that breaks
> ABIs so it can't be used generally.)
Unless I misunderstand, although GCC may define the rank of an enum type to
be as large as an int; it should arguably (in the interest of efficiency),
define it to be as small as the smallest standard integer type capable of
representing it's value range. (shouldn't it?)
6.2.1.1 Characters and integers
- The rank of any enumerated type shall equal the rank of
the compatible integer type.
6.5.2.2 Enumeration specifiers
[#4] Each enumerated type shall be compatible with an
integer type. The choice of type is implementation-defined,
but shall be capable of representing the values of all the
members of the enumeration.