I have successfully built arrays at compile-time, basically an array
of pointers to data. I just use build_constructor() and build the
elements using the CONSTRUCTOR_APPEND_ELT() macro. Anyways. I am in
a bit of confusion. I have a data type, and need the array in this
data type to be variable. Here is essentially trying to create. I do
not want to build an array of pointers to data.
struct my_info_t {
int id;
int n_members;
other_data_t members[];
};
I can generate instances of my_info_t fine, with the 'id' and
'n_member' fields all correct; however, the 'members' field never
seems to contain any data. In fact, the compiler ICEs. In a loop, I
create a member instance and add it to the 'members' field via:
CONSTRUCTOR_APPEND_ELT(members, NULL, member);
Now, member is created as a global variable and I am appending the
actual decl into the 'members' field. So, in the line above, 'member'
is actually a decl.
When it comes time to add the 'members' array to to my_info_t
constructor, I create a decl for the members array, so 'members' is a
decl. The initial part of the
The DECL_INITIAL of 'members' is the result of
build_constructor(member_array_type, members). I append this decl:
CONSTRUCTOR_APPEND_ELT(myinfo_instance, field, members); // members is a decl
When I finalize the 'members' decl (varpool_finalize_decl) I get a
compiler ICE in cgraphbuild.c:67 (gcc-4.7.1), as the type is
unreachable. The unreachable being the decl, instance of the member.
Should both the member and members array be DECL nodes that have their
DECL_INITIAL field set to the respected results from calling
build_constructor() for the member instance and members array?
-Matt