This is the mail archive of the gcc-patches@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]

[C++ PATCH] PING: Rewrite convert_nontype_argument


Hello Jason,

this is my updated patch of the rewrite of convert_nontype_argument. Some
context for you:

-- First sent here: http://gcc.gnu.org/ml/gcc-patches/2004-07/msg01605.html.
You reviewed it right away and had some questions (see the followup).

-- Take two, addressing your concerns and answering your questions:
http://gcc.gnu.org/ml/gcc-patches/2004-09/msg00226.html

-- Mark said it was OK with him but wanted to hear your opinion:
http://gcc.gnu.org/ml/gcc-patches/2004-09/msg00232.html. He also found
problem in my patch related to division by zeros.

Now this is the (hopefully) final patch, updated against today mainline. It
addresses Mark's concerns by removing the wrong hunk in build_binary_op, and
instead it now directly checks for INTEGER_CST instead of TREE_CONSTANT:


  if (INTEGRAL_TYPE_P (type))
    {
      if (!INTEGRAL_TYPE_P (expr_type))
        return error_mark_node;

      expr = fold_decl_constant_value (expr);
      /* Notice that there are constant expressions like '4 % 0' which
         do not fold into integer constants.  */
      if (TREE_CODE (expr) != INTEGER_CST)
        {
          error ("%qE is not a valid template argument for type %qT "
                 "because it is a non-constant expression", expr, type);
          return NULL_TREE;
        }



There are also two additional differences from take two:

-- fold_decl_constant_value is now public instead of being static. I have
plans to use this function to fold constant expressions within GNU
attributes.

-- I know fold the resolt of the conversion of an integral constant through
fold(). This is needed to not confuse the mangler, which does not strip the
NOPs and thus does not see the constant (see mangle.c:write_template_arg).
Without this call, g++.dg/abi/mangle16.C fails (notice: this was not needed
one month ago, but it is now).

I would be grateful if you could find some time to review this patch, I have
been updating it for 3 months now. Tested on i686-pc-linux-gnu, OK for
mainline?

Giovanni Bajo

Attachment: patch-rewrite-cnta.txt
Description: Text document


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