On Mon, Aug 19, 2024 at 05:18:14PM -0400, Jason Merrill wrote:
> > The following patch parses it there, for the non-outermost arrays
> > applies normally the attributes to the array type, for the outermost
> > where we just set *nelts and don't really build an array type just
> > warns that we ignore those attributes (or, do you think we should
> > just build an array type in that case and just take its element type?).
> 
> It seems cleaner to just build an array type, and build_new_1 appears to
> already handle that.  But I don't think there are currently any attributes
> that would be useful in this position, so this patch is fine with a FIXME if
> you don't want to mess with it.

Unfortunately it isn't that easy to build the array, at least not by
not stripping that one declarator, doing groktypename and then stripping
the outermost array from it.
The problem is that C++ pedantically doesn't support VLAs and the
outermost new "array" is the only one which can be validly a VLA.
So, we'd need to arrange for the VLA pedwarn to be disabled for the
outermost array but enabled for the inner ones, as we want to pedwarn on
new int[4][n]
or
new int[n][n]
but not
new int[n][4]
Sure, we can just build the array manually without going through
groktypename and immediately throw it away, but I mean if we'd actually
never use that array for anything, it still might make sense to warn
users that we are actually completely ignoring any (non-ignored) attribute
there.

        Jakub

Reply via email to