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: [PATCH] Fix PR C++/28906, fallout from the fix for PR 27184


> 
> Andrew Pinski wrote:
> > -      full_type = build_cplus_array_type (type, NULL_TREE);
> >        index = convert (sizetype, nelts);
> >        index = size_binop (MINUS_EXPR, index, size_one_node);
> > -      TYPE_DOMAIN (full_type) = build_index_type (index);
> > +      index = build_index_type (index);
> > +      full_type = build_cplus_array_type (type, NULL_TREE);
> > +      /* We need a copy of the type as build_array_type will return a shared copy
> > +         of the incomplete array type.  */
> > +      full_type = build_distinct_type_copy (full_type);
> > +      TYPE_DOMAIN (full_type) = index;
> 
> Why not just pass the index type to build_cplus_array_type?

Because we will then reject the following valid code:
int n;
int *x = new int[n];

as the middle-end thinks we are creating a VLA out side of
a function as we have not set up the function to hold non constant
initializers yet.

Thanks,
Andrew Pinski


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