C++ patch ping

Jakub Jelinek jakub@redhat.com
Mon Apr 28 20:43:00 GMT 2008


On Mon, Apr 28, 2008 at 10:06:35AM -0700, Mark Mitchell wrote:
> Jakub Jelinek wrote:
> 
> >- http://gcc.gnu.org/ml/gcc-patches/2008-04/msg01609.html	PR c++/35650
> 
> I think this patch is OK.  As you say, we could also change 

Thanks.

> >- http://gcc.gnu.org/ml/gcc-patches/2008-04/msg01559.html	PR c++/35987
> 
> This is OK, too, though I would prefer using error_operand_p to the 
> direct comparision with error_mark_node.  In this case, error_mark_node 
> is probably correct -- but using error_operand_p for expressions is more 
> mnemonic.

cp_build_modify_expr starts with:

  /* Avoid duplicate error messages from operands that had errors.  */
  if (error_operand_p (lhs) || error_operand_p (rhs))
    return error_mark_node;

so it should turn many results
res != error_mark_node && TREE_TYPE (res) == error_mark_node
into error_mark_node.  And the following cases also use direct
error_mark_node comparison:

      /* Handle (a, b) used as an "lvalue".  */
    case COMPOUND_EXPR:
      newrhs = cp_build_modify_expr (TREE_OPERAND (lhs, 1),
                                     modifycode, rhs, complain);
      if (newrhs == error_mark_node)
^^^^ here
        return error_mark_node;
      return build2 (COMPOUND_EXPR, lhstype,
                     TREE_OPERAND (lhs, 0), newrhs);

    case MODIFY_EXPR:
      if (TREE_SIDE_EFFECTS (TREE_OPERAND (lhs, 0)))
        lhs = build2 (TREE_CODE (lhs), TREE_TYPE (lhs),
                      stabilize_reference (TREE_OPERAND (lhs, 0)),
                      TREE_OPERAND (lhs, 1));
      newrhs = cp_build_modify_expr (TREE_OPERAND (lhs, 0), modifycode, rhs,
                                     complain);
      if (newrhs == error_mark_node)
^^^^ and here
        return error_mark_node;
      return build2 (COMPOUND_EXPR, lhstype, lhs, newrhs);
(and later code in the function does similarly).

So, if I should use error_operand_p instead, I guess it should be changed
consistently for all 3 cases, or none.

	Jakub



More information about the Gcc-patches mailing list