[PATCH] Fix dwarf2out/dbxout ICE on anonymous variable length structs/unions (PR debug/33316)

Mark Mitchell mark@codesourcery.com
Mon Sep 24 06:55:00 GMT 2007


Richard Guenther wrote:
> On 9/20/07, Jakub Jelinek <jakub@redhat.com> wrote:
>> Hi!
>>
>> This is another fallout of the
>> http://gcc.gnu.org/ml/gcc-patches/2006-10/msg00239.html
>> change, {dwarf2,dbx}out don't expect DECL_NAME to be NULL on
>> TYPE_DECL provided as TYPE_NAME () of some RECORD_TYPE/UNION_TYPE.
>>
>> The TYPE_DECL is there to make sure the sizes are gimplified
>> at the right place, but the type really doesn't have a name
>> and so no name should be emitted into the debugging info.
>>
>> Ok for 4.2/trunk?
> 
> Ok for trunk, for 4.2 ask Mark (or wait after 4.2.2).

This is OK for 4.2.2.

>> 2007-09-20  Jakub Jelinek  <jakub@redhat.com>
>>
>>         PR debug/33316
>>         * dwarf2out.c (modified_type_die): Handle TYPE_DECL with NULL
>>         DECL_NAME.
>>         * dbxout.c (dbxout_type): Likewise.
>>
>>         * gcc.dg/debug/pr33316.c: New test.
>>
>> --- gcc/dwarf2out.c.jj  2007-09-05 21:38:53.000000000 +0200
>> +++ gcc/dwarf2out.c     2007-09-20 20:20:09.000000000 +0200
>> @@ -8724,7 +8724,8 @@ modified_type_die (tree type, int is_con
>>       don't output a DW_TAG_typedef, since there isn't one in the
>>       user's program; just attach a DW_AT_name to the type.  */
>>    if (name
>> -      && (TREE_CODE (name) != TYPE_DECL || TREE_TYPE (name) == qualified_type))
>> +      && (TREE_CODE (name) != TYPE_DECL
>> +         || (TREE_TYPE (name) == qualified_type && DECL_NAME (name))))
>>      {
>>        if (TREE_CODE (name) == TYPE_DECL)
>>         /* Could just call add_name_and_src_coords_attributes here,

I think the comment is giving us a hint about how we can make this
simpler.  In particular:

  if (name)
    {
       if (TREE_CODE (name) == TYPE_DECL
           && TREE_TYPE (name) == qualified_type)
         add_name_and_src_coords (mod_type_die, name);
       else if (TREE_CODE (name) == IDENTIFIER_NODE)
         add_name_attribute (mod_type_die, IDENTIFIER_POINTER (name));
    }

There's no reason not to use add_name_and_src_coords in the TYPE_DECL
case, and that makes it more obvious what's going on.  In particular, it
already handles DECL_NAME being NULL, so would eliminate this check
here.  So, I would recommend that we use that formulation on mainline,
but that's a minor point.

Thanks,

-- 
Mark Mitchell
CodeSourcery
mark@codesourcery.com
(650) 331-3385 x713



More information about the Gcc-patches mailing list