This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Question on building a variably modified type at parameter scope
- From: Ian Lance Taylor <iant at google dot com>
- To: YU Chenkan <cyuaa at ust dot hk>
- Cc: gcc at gcc dot gnu dot org
- Date: Tue, 5 Mar 2013 06:49:13 -0800
- Subject: Re: Question on building a variably modified type at parameter scope
- References: <52207.143.89.244.110.1362487743.squirrel@sqmail.ust.hk>
On Tue, Mar 5, 2013 at 4:49 AM, YU Chenkan <cyuaa@ust.hk> wrote:
>
> I'm a newbie and I'm trying to modify the front end to extend C.
>
> I know the following code can be accepted,
>
> void f (struct S { int a; } s, int a[][s.a]) { } .
>
> I'm wondering whether it is possible to build a structure which has a
> variably modified array whose size depends on an other field in that
> structure at parameter scopes,
> i.e, something like this,
>
> void f (struct S { int a; int b[s.a]; } s) { } .
>
> This won't be compiled as s is not declared when build the struct S, but
> by modifying the front end code, I can mimic this directly. However, the
> assertion,
>
> gcc_assert (SA.partition_to_pseudo[i]);
>
> in the function gimple_expend_cfg in cfgexpand.c fails, and I've no idea
> why.
I believe this should be possible. I believe that Ada has constructs
like this. I think you will need to use a PLACEHOLDER_EXPR to get the
right thing to happen.
Ian