Patch to allow Ada to work with tree-ssa
Nathan Sidwell
nathan@codesourcery.com
Wed Jun 23 11:17:00 GMT 2004
Richard Kenner wrote:
> [I'm moving this to the gcc list and off gcc-patches]
>
> this is my point. What is the point of this extension?
> * It's not documented, so users have no formal knowledge of its existance
> * It's not documented, so users have no guarantee that it'll continue
> to work
>
> Historically, very few C programs read standards or give any thought at all
> to what's "guaranteed". If anything, I'd suspect that practice to have
> gotten worse.
this is absolutely no argument for not documenting it!
> Then document it. And the fact that it didn't work properly, and
> you're having such grief getting it working seems to imply 'easily
> support' is not actually true.
>
> I'm not sure exactly what you're asking to document. We document that GNU C
> allow variable-sized arrays in general. It's part of C that you can put an
> arbitrary type inside a struct.
Neither of these is true.
1) we do not document this use. the documentation (extend.texi) has this
to say about variable-length arrays,
--snip
Variable-length automatic arrays are allowed in ISO C99, and as an
extension GCC accepts them in C89 mode and in C++. (However, GCC's
implementation of variable-length arrays does not yet conform in detail
to the ISO C99 standard.) These arrays are
declared like any other automatic arrays, but with a length that is not
a constant expression. The storage is allocated at the point of
declaration and deallocated when the brace-level is exited. For
example:
--snip
It does *not* say variable length arrays are supported in all the places
fixed sized arrays are (because we don't) -- which is what I presume is what
you mean by 'GNU C allow[s] variable-sized arrays in general'. Nor does
it give additional special cases such as putting a variable length array
in the middle (or end) of a struct. Nor does it say a struct with a
variable length array in it can be an automatic (or any other kind of)
variable.
2) You cannot put an arbitrary type inside a struct. prior to C99
you could not put an incomplete array in a struct at all, and in C99
there are restrictions on where you can put it (and recursive restrictions
on where you can place a struct with an incomplete array member).
> What I meant by "easily support" is that since it's needed for Ada anyway,
> the cost of doing it for C too is trivial.
If it's only truely needed for Ada, then it could beconstrained to the
Ada front end and have *no* impact on the rest of the compiler (but
I've not been closely following this thread and it looks like fortran
has some uses wrt arrays with varying strides and I guess there
are reasons to make it visible in gimple).
> I'd like to know how many real (not a testcase) GNU C programs out
> there use this varray-in-middle idiom (really, I would).
>
> Unfortunately, there's no way to get that data.
Well, nobody here has come up with any non-toy C example -- the PR Joseph
pointed to used a trailing array. Plus that it *doesn't work* in some
cases indicates that perhaps it's not actually used outside of Ada.
nathan
--
Nathan Sidwell :: http://www.codesourcery.com :: CodeSourcery LLC
nathan@codesourcery.com :: http://www.planetfall.pwp.blueyonder.co.uk
More information about the Gcc
mailing list