| Submitter | Basile Starynkevitch |
|---|---|
| Date | Nov. 5, 2010, 7:41 p.m. |
| Message ID | <20101105204156.a8dfec12.basile@starynkevitch.net> |
| Download | mbox | patch |
| Permalink | /patch/70287/ |
| State | New |
| Headers | show |
Comments
> The following patch seems to correct a bug in > get_output_file_for_structure. Otherwise, could anyone explain why the > original thing worked? I suspect it is it was never called with a > TYPE_PARAM_STRUCT, or for some other reason I cannot understand. I've investigated and it's almost true that it was never called with a TYPE_PARAM_STRUCT. However I have introduced write_splay_tree_allocator_def which calls it with TYPE_PARAM_STRUCT only, which then tries to read location information through the wrong member of the union and by chance finds a NULL there, resulting in gtype-desc.c output file, which by chance is correct. Not the best state of the things. Thus your patch is, unfortunately, not OK, and the proper fix would be - replace get_output_file_for_structure with get_output_file_with_visibility(NULL) in write_splay_tree_allocator_def; - in get_output_file_for_structure put a gcc_assert that s is UNION_OR_STRUCT_P only. Would you be willing to do this? Thanks,
Patch
Index: gcc/gengtype.c =================================================================== --- gcc/gengtype.c (revision 166376) +++ gcc/gengtype.c (working copy) @@ -2637,9 +2637,14 @@ output_type_enum (outf_p of, type_p s) static outf_p get_output_file_for_structure (const_type_p s, type_p *param) { - const char *fn = s->u.s.line.file; + const char *fn; int i; + if (UNION_OR_STRUCT_P (s)) + fn = s->u.s.line.file; + else if (s->kind == TYPE_PARAM_STRUCT) + fn = s->u.param_struct.line.file; + /* This is a hack, and not the good kind either. */ for (i = NUM_PARAM - 1; i >= 0; i--) if (param && param[i] && param[i]->kind == TYPE_POINTER
The following patch seems to correct a bug in get_output_file_for_structure. Otherwise, could anyone explain why the original thing worked? I suspect it is it was never called with a TYPE_PARAM_STRUCT, or for some other reason I cannot understand. ############## gcc/ChangeLog entry 2010-11-05 Basile Starynkevitch <basile@starynkevitch.net> * gengtype (get_output_file_for_structure): Fix computation of file name for a TYPE_PARAM_STRUCT ############## Ok for trunk?