Giovanni Bajo wrote:

But how are you proposing to handle the fact that the C++ FE needs to fold
constant expressions (in the ISO C++ sense of 'constant expressions)? For
instance, we need to fold "1+1" into "2" much before gimplification. Should
a part of fold() be extracted and duplicated in the C++ frontend?

This has actually already been discussed.

We don't need anything like the generality of fold. All we need is the ability to perform basic arithmetic on integer constants. (And, perhaps, as an extension, floating-point constants.) In fact, it is better not to use "fold"; we want to make sure that the semantics are 100% under the control of the C++ front end.

We just need to write a recursive routine that works in the obvious way:

  switch (code) {
  case PLUS_EXPR:
    return int_const_binop (PLUS_EXPR, cxx_fold (op1), cxx_fold (op2));
  ...
  }

and use it in fold_non_dependent_expr, and other similar places. (Since we're no longer calling fold, tsubst_copy_and_build will give us back a tree that needs to be simplified; that's were we call cxx_fold.)

--
Mark Mitchell
CodeSourcery, LLC
[EMAIL PROTECTED]
(916) 791-8304

Reply via email to