On Tue, Mar 20, 2018 at 5:55 PM, Alexandre Oliva <aol...@redhat.com> wrote:
> On Mar 20, 2018, Jason Merrill <ja...@redhat.com> wrote:
>
>> On Sat, Mar 17, 2018 at 8:11 AM, Alexandre Oliva <aol...@redhat.com> wrote:
>>> -           sorry
>>> -             ("cannot initialize multi-dimensional array with 
>>> initializer");
>
>> This shouldn't even be a sorry anymore
>
>> Let's make it a hard error here.
>
> Like this?
>
>
> [PR c++/71965] silence multi-dim array init sorry without tf_error
>
> We shouldn't substitute templates into short-circuited-out concepts
> constraints, but we do, and to add insult to injury, we issue a
> sorry() error when a concept that shouldn't even have been substituted
> attempts to perform a multi-dimensional array initialization with a
> new{} expression.
>
> Although fixing the requirements short-circuiting is probably too
> risky at this point, we can get closer to the intended effect by
> silencing that sorry just as we silence other errors.
>
> Regstrapping...  Ok to install if it passes?
>
> for  gcc/cp/ChangeLog
>
>         PR c++/71965
>         * init.c (build_vec_init): Silence error, former sorry,
>         without tf_error.
>
> for  gcc/testsuite/ChangeLog
>
>         PR c++/71965
>         * g++.dg/concepts/pr71965.C: New.
> ---
>  gcc/cp/init.c                           |   19 ++++++++++++-------
>  gcc/testsuite/g++.dg/concepts/pr71965.C |   27 +++++++++++++++++++++++++++
>  2 files changed, 39 insertions(+), 7 deletions(-)
>  create mode 100644 gcc/testsuite/g++.dg/concepts/pr71965.C
>
> diff --git a/gcc/cp/init.c b/gcc/cp/init.c
> index 9091eaa90267..5dd4b407d73f 100644
> --- a/gcc/cp/init.c
> +++ b/gcc/cp/init.c
> @@ -4384,12 +4384,17 @@ build_vec_init (tree base, tree maxindex, tree init,
>        else if (TREE_CODE (type) == ARRAY_TYPE)
>         {
>           if (init && !BRACE_ENCLOSED_INITIALIZER_P (init))
> -           sorry
> -             ("cannot initialize multi-dimensional array with initializer");
> -         elt_init = build_vec_init (build1 (INDIRECT_REF, type, base),
> -                                    0, init,
> -                                    explicit_value_init_p,
> -                                    0, complain);
> +           {
> +             if ((complain & tf_error))
> +               error ("cannot initialize multi-dimensional"
> +                      " array with initializer");

Let's also use the other diagnostic message: "array must be
initialized with a brace-enclosed initializer".

OK with that change.

Jason

Reply via email to