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]

Re: [C++ Patch] Add maybe_constant_folded_value


Hi,

On 11/14/2014 03:35 AM, Jason Merrill wrote:
On 11/13/2014 04:31 PM, Paolo Carlini wrote:
I think this should be replaced with fold_ if
(processing_template_decl) in build_enumerator.
Ok. The value can be NULL_TREE, thus in a straightforward change (per
the below) I have to check for that, otherwise we crash in
maybe_constant_value. Either that or just check for NULL_TREE at the
beginning of maybe_constant_value itself, I guess.

The current fold_ already checks for NULL_TREE; I think we want to preserve that behavior.
Ok, I added it to the new fold_.

This is the relatively most tricky change: we have a regression for
init/array11.C, because the gcc_assert at the end of
maybe_constant_value (called by maybe_constant_init) triggers:

   gcc_assert (r == t
           || CONVERT_EXPR_P (t)
           || (TREE_CONSTANT (t) && !TREE_CONSTANT (r))
           || !cp_tree_equal (r, t));

we have VIEW_CONVERT_EXPRs, neither is constant, r != t and
cp_tree_equal is true. Wild guess: are VIEW_CONVERT_EXPRs also Ok?

Yes.
Ok.

What did you think about avoiding the duplicate instantiation_dependent_expression_p and potential_constant_expression checks?
Frankly at some point I forgot that, sorry.

Today I figured out the below: the new fold_non_dependent_expr is much bigger but definitely calls instantiation_dependent_expression_p and potential_constant_expression at most once and should be always logically equivalent to instantiate_non_dependent_expr_sfinae followed by maybe_constant_value, even in the special cases of those TREE_OVERFLOW_Ps. Note: among various other simplifications, I tried removing the early return via the conditional:

      if (type_unknown_p (t)
          || BRACE_ENCLOSED_INITIALIZER_P (t))

but it's actually used by eg, g++.dg/cpp0x/constexpr-initlist5.C.

I'm attaching what passed testing on x86_64-linux.

Thanks!
Paolo.

//////////////////////////////

Attachment: patchlet4
Description: Text document


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