On Mon, Jul 18, 2016 at 2:03 PM, Jakub Jelinek <ja...@redhat.com> wrote:
> On Mon, Jul 18, 2016 at 01:16:26PM -0400, Jason Merrill wrote:
> That is reasonable, but not 100% sure what to do if it returns NULL
> - it should return t, but if I do VERIFY_CONSTANT (t); there or
> manually
>     if (!*non_constant_p)
>       {
>         if (!allow_non_constant)
>           error ("%q+E is not a constant expression", t);
>         *non_constant_p = true;
>       }
>     return t;
> it will print the original expression (without folded arguments).
> Another option would be to build_call_array_loc if we want to emit
> the error.  Preferences?

Hmm, I guess let's build the call for the error.

>    /* Fold away the NOP_EXPR from fold_builtin_n.  */
>    new_call = fold (new_call);
>    force_folding_builtin_constant_p = save_ffbcp;
> +
> +  /* Folding some math builtins produces e.g. COMPOUND_EXPR etc.  */
> +  if (cxx_dialect >= cxx14)
> +    return cxx_eval_constant_expression (&new_ctx, new_call, lval,
> +                                        non_constant_p, overflow_p);

If we do this unconditionally, can we drop the fold above?

Jason

Reply via email to