[cfe-dev] Better type-specifier representation

Daniel Dunbar daniel at zuster.org
Sat Sep 13 13:16:05 PDT 2008


I agree with Argiris that the same AST node represents these things (i.e.
an array which has a size expression instead of constant). Calling this
node a VLA node is a misnomer, however.

It is sema's responsibility to make sure that this node makes sense given
the current language (i.e. is it a VLA? Is it an array with a size expression
which evaluates to a constant and is thus accepted by gcc as a valid array
in non-C99? Similar situation for C++...).

And it is LLVM IR generation's responsibility to do the right thing
with it. For downstream convenience we may want Sema to annotate
such nodes with information about what the "array with size expression"
actually is.

In my opinion, the owner of the expression should most certainly be the
declaration. In fact, I'm not even sure it is correct for the size expression
to be in the type, but I haven't taken the time to fully understand VLA
rules and the interaction with what gcc accepts yet.

I'm fairly certain that this issue is independent of the type specifier one,
however.

 - Daniel

On Sat, Sep 13, 2008 at 12:33 PM, Eli Friedman <eli.friedman at gmail.com> wrote:
> On Sat, Sep 13, 2008 at 12:04 PM, Mike Stump <mrs at apple.com> wrote:
>>> Nevertheless, should we treat these as VLAs in the ASTs?
>>
>> I propose that we treat VLAs as VLAs and non-VLAs by a name other than
>> VLA?!  I shudder to think anyone would want something different.
>> Surely I must misunderstand something.
>
> If I recall correctly, in C++, in "const int i = 10; int a[i];", the
> declaration of a is valid (and not a VLA) because "i" is a constant
> expression (as opposed to C99, where it is a VLA).
>
> In any case, I can't figure out what owns the expression in the
> braces; I wouldn't be surprised if it leaks.
>
> -Eli
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
>



More information about the cfe-dev mailing list