On 20/03/07, Jakub Jelinek <[EMAIL PROTECTED]> wrote:
On Tue, Mar 20, 2007 at 11:04:16AM -0600, Kevin Handy wrote:
> >#define LANG_TREE_CODE(NODE) (TREE_CODE (NODE) == LANG_CODE ?
> >((tree_with_subcode *)(NODE))->subcode : TREE_CODE (NODE))
> >
> This subcode idea feels like a bug attractor to me.
>
> For example: #defines have enough problems with
> side effects, and this references NODE twice, so
> what happens when NODE is a function of some
> kind, or has other side effects?
Just look quickly at tree.h, there are plenty of other macros already
that evaluate their arguments multiple times.
> >switch contains >= 256 FE specific subcodes you'd use LANG_TREE_CODE
> >instead of TREE_CODE. GCC would warn you if you forget to use
> >LANG_TREE_CODE even when it is needed, at least in switches, you'd get
> >warning: case label value exceeds maximum value for type
> >
> I'd expect that the TREE_CODE would be referenced
> more often in comparisons, than in switch statements.
> These probably wouldn't generate the warning.
That warns too, see (-Wall):
Just to be precise, that warning is not in Wall, it is enabled by
default and there have been continous requests to assign it a switch
(so it can be disabled) and move it to -Wextra. Unreviewed patch
available here:
http://gcc.gnu.org/ml/gcc-patches/2007-03/msg00207.html
Cheers,
Manuel.