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): enum foo { A=0, B=1, C=2, X=254, Y=255 }; struct tree { enum foo code : 8; }; extern void bar (void); void foo (struct tree *t) { switch (t->code) { case C: break; case 512: bar (); break; case 1081: break; } if (t->code == 1024) bar (); if (t->code != 1035) bar (); } Jakub