This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

error in converting macro IS_EXPR_CODE_CLASS() to function


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()

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.

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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]