C++: enable-checking patches

Mark Mitchell mark@codesourcery.com
Tue Nov 30 23:59:00 GMT 1999


>>>>> "Martin" == Martin v Loewis <martin@mira.isdn.cs.tu-berlin.de> writes:

    Martin> Notice how it has a template-info, which in turn has the
    Martin> template_decl.

OK.

    Martin> Well, my commentary should read: In mark_used ...  There,
    Martin> I have the patch

OK.

    Martin> I widened the test, and removed the explanation why you
    Martin> checked for TEMPLATE_DECL. Sorry about the confusion.

OK.

    Martin> 4. finish_unary_op_expr reported a problem when
    Martin> TREE_NEGATED_INT was set for a NEGATE_EXPR (when it was
    Martin> documented only for INTEGER_CSTs). The problem was that
    Martin> build_x_unary_op would normally fold INTEGER_CSTs - except
    Martin> inside templates. Fold these constants now even inside
    Martin> templates.
    >>  I don't think we should do this.  I'm nervous about doing much
    >> of anything inside a template.  Instead, just have
    >> finish_unary_op_expr check to see that the resulting thing is
    >> an INTEGER_CST.

    Martin> What is the official interface for folding such a thing? I
    Martin> tried to call fold() on the resulting expression, ie.

The point is that we don't want to fold it.  We'll do that later, when
instantiating it.  I think all you need to do is:

  tree result = build_x_unary_op (code, expr);
  if (code == NEGATE_EXPR && TREE_CODE (expr) == INTEGER_CST
      && TREE_CODE (result) == INTEGER_CST)
    TREE_NEGATED_INT (result) = 1;

Does that make sense?  If it does, and it works, consider it
pre-approved after you test it.

Thanks!

--
Mark Mitchell                   mark@codesourcery.com
CodeSourcery, LLC               http://www.codesourcery.com



More information about the Gcc-patches mailing list