https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77697

            Bug ID: 77697
           Summary: suspicious code in tree-ssa-forwprop.c
           Product: gcc
           Version: 7.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: bernd.edlinger at hotmail dot de
  Target Milestone: ---

Hi,

was playing with a new experimental version of my -Wint-in-bool-context
warning.

It catched this code in tree-ssa-forwprop.c

../../gcc-trunk/gcc/tree-ssa-forwprop.c: In function 'void
defcodefor_name(tree, tree_code*, tree_node**, tree_node**)':
../../gcc-trunk/gcc/tree-ssa-forwprop.c:1477:8: error: using integer constants
in boolean context [-Werror=int-in-bool-context]
     || GIMPLE_BINARY_RHS
        ^~~~~~~~~~~~~~~~~
../../gcc-trunk/gcc/tree-ssa-forwprop.c:1478:8: error: using integer constants
in boolean context [-Werror=int-in-bool-context]
     || GIMPLE_UNARY_RHS
        ^~~~~~~~~~~~~~~~
../../gcc-trunk/gcc/tree-ssa-forwprop.c:1479:8: error: using integer constants
in boolean context [-Werror=int-in-bool-context]
     || GIMPLE_SINGLE_RHS)
        ^~~~~~~~~~~~~~~~~


  else if (grhs_class == GIMPLE_TERNARY_RHS
           || GIMPLE_BINARY_RHS
           || GIMPLE_UNARY_RHS
           || GIMPLE_SINGLE_RHS)
    extract_ops_from_tree (name, &code1, &arg11, &arg21, &arg31);

enum gimple_rhs_class
{
  GIMPLE_INVALID_RHS,   /* The expression cannot be used on the RHS.  */
  GIMPLE_TERNARY_RHS,   /* The expression is a ternary operation.  */
  GIMPLE_BINARY_RHS,    /* The expression is a binary operation.  */
  GIMPLE_UNARY_RHS,     /* The expression is a unary operation.  */
  GIMPLE_SINGLE_RHS     /* The expression is a single object (an SSA
                           name, a _DECL, a _REF, etc.  */
};

I think what was really meant is:

  else if (grhs_class == GIMPLE_TERNARY_RHS
           || grhs_class == GIMPLE_BINARY_RHS
           || grhs_class == GIMPLE_UNARY_RHS
           || grhs_class == GIMPLE_SINGLE_RHS)
    extract_ops_from_tree (name, &code1, &arg11, &arg21, &arg31);

Reply via email to