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: [PR c++/84729] convert new init to array elt type


On Tue, Mar 20, 2018 at 5:56 PM, Alexandre Oliva <aoliva@redhat.com> wrote:
> On Mar 20, 2018, Jason Merrill <jason@redhat.com> wrote:
>
>> On Sat, Mar 10, 2018 at 6:57 AM, Alexandre Oliva <aoliva@redhat.com> wrote:
>>> A parenthesized initializer is only accepted when new()ing an array in
>>> permissive mode.  We were not careful, however, to convert the
>>> TREE_LIST initializer to the array element type in this extension.
>>> This patch fixes it: after turning the TREE_LIST initializer to a
>>> compound_expr, we convert it to the base type.
>
>> I think I'd rather turn the permerror into a hard error than improve
>> support for a deprecated extension.
>
> Like this?
>
> [PR c++/84729] convert new init to array elt type
>
> A parenthesized initializer was only accepted when new()ing an array in
> permissive mode.  We were not careful, however, to convert the
> TREE_LIST initializer to the array element type in this extension.
>
> Instead of fixing it, converting the initializer to the base type
> after turning the TREE_LIST initializer to a compound_expr, we disable
> this deprecated extension.
>
> Regstrapping.  Ok to install if it passes?
>
> for  gcc/cp/ChangeLog
>
>         PR c++/84729
>         * init.c (build_vec_init): Convert tree list to base type.
>
> for  gcc/testsuite/ChangeLog
>
>         PR c++/84729
>         * g++.dg/pr84729.C: New.
> ---
>  gcc/cp/init.c                  |    4 ++--
>  gcc/testsuite/g++.dg/pr84729.C |    7 +++++++
>  2 files changed, 9 insertions(+), 2 deletions(-)
>  create mode 100644 gcc/testsuite/g++.dg/pr84729.C
>
> diff --git a/gcc/cp/init.c b/gcc/cp/init.c
> index 15cee17c780c..9091eaa90267 100644
> --- a/gcc/cp/init.c
> +++ b/gcc/cp/init.c
> @@ -3370,8 +3370,8 @@ build_new_1 (vec<tree, va_gc> **placement, tree type, tree nelts,
>           else if (*init)
>              {
>                if (complain & tf_error)
> -                permerror (input_location,
> -                          "parenthesized initializer in array new");
> +                error_at (input_location,
> +                         "parenthesized initializer in array new");
>                else
>                  return error_mark_node;

I suspect you'll need to make the return unconditional to avoid the
ICE; OK either way.

Jason


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