On Mon, Dec 23, 2013 at 09:26:41AM -0500, Prathamesh Kulkarni wrote:
> IS_EXPR_CODE_CLASS() is called at 18 places within gcc subdirectory,
> and except for expr_check(), tree_block(), tree_set_block() all the
> other callers pass argument of type enum tree_code_class to
> IS_EXPR_CODE_CLASS().
>
> These four callers (expr_check is overloaded) assign value of
> TREE_CODE_CLASS() to variable of type char const, and then pass it as
> argument to IS_EXPR_CODE_CLASS()
that sounds like a bug, or at least a aimed and loaded foot gun
> For example: tree_block():
> tree
> tree_block (tree t)
> {
> char const c = TREE_CODE_CLASS (TREE_CODE (t));
>
> if (IS_EXPR_CODE_CLASS (c))
> return LOCATION_BLOCK (t->exp.locus);
> gcc_unreachable ();
> return NULL;
> }
>
> Should type of "c" be changed to const enum tree_code_class instead
> (similarly in other callers) ? Also, TREE_CODE_CLASS()'s value is of
> type enum tree_code_class.
Well, in that case using a local variable seems pretty useless, why not
just get rid of it? However switching the type certainly seems
reasonable.
Trev
>
> This gave a compile-error: invalid conversion from ‘char’ to ‘tree_code_class’
> when i changed the macro IS_EXPR_CODE_CLASS() to the following function:
>
> static inline bool
> IS_EXPR_CODE_CLASS(enum tree_code_class code_class)
> {
> return (code_class >= tcc_reference) && (code_class <= tcc_expression);
> }
>
> Thanks and Regards,
> Prathamesh