Re: Question on building a variably modified type at parameter scope

2013-03-08 Thread YU Chenkan
I found this is a bug in my front end because I used the same type for the
parameters in different functions, so the references to the parameter in
the structure messed up.

The thing I want to implement is creating something like this pointers in
C++ of structure type whose variably modified fields depend on other
fields.

So the problem is the reference of this parameter differs from function to
function, and therefore, in the most straightforward solution, I have to
deep copy the whole structure for each function, so it can correctly refer
to the parameter.

However, I want to avoid the deep copy.

So, first, I guess it's not safe to share the same PARM_DECL among
different functions, is it true?

If true, is it possible to refer to the first parameter of whatever
functions in the same way, so I can use the same type built upon that
reference?

And if so, at which stage, I can build such a reference?

Thanks,
Chenkan

>> 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.
>
> In Ada, we indeed have the mechanism in its full generality, i.e.
>
>   struct S { int a; int b[a]; };
>
> will work anywhere, and for this the PLACEHOLDER_EXPR machinery is needed.
>
> But it seems to me that the case at stake is more specific:
>
>   void f (struct S { int a; int b[s.a]; } s) { }
>
> because struct S is defined at parameter scope and s.a is a known object,
> so
> perhaps the use of the (heavy) PLACEHOLDER_EXPR machinery could be
> avoided.
>
> --
> Eric Botcazou
>




Generating data at link time

2013-06-01 Thread YU Chenkan
Dear all,

  I'm trying to generate a (very simple) special data section at
link-time. It seems that LTO is too heavy, though I'm also not quite
familiar with it.

  I think that what I first need is a new output format which wraps the
standard ELF, so can anyone help to point out where I can get started?

  Also if I want to generate data, is there any tool lighter than and
compatible with GCC can be used to deal with the platform dependent
stuff?



Question on building a variably modified type at parameter scope

2013-03-05 Thread YU Chenkan
HI,

  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'm using 4.6.3.

Thanks,
Chenkan