patch to fix tentative struct type collision

Fariborz Jahanian fjahanian@apple.com
Tue Dec 5 19:25:00 GMT 2006


When searching for a tentative struct type in type_hash_eq, if it  
collides with another similar type, currently type_hash_eq says it is  
a match since both types' TYPE_FIELDS is NULL. This is incorrect and  
causes bad things to happen as it matches "struct foo' with "struct  
bar", for example. I ran into this problem when made a call to  
build_type_attribute_variant to create a new duplicate type with new  
attributes. Attach patch, which is dejagnu and bootstrap tested on  
apple-x86-darwin, fixes the problem.

OK for FSF's main trunk?

- Fariborz (fjahanian@apple.com)

ChangeLog:

2006-12-05  Fariborz Jahanian  <fjahanian@apple.com>

         * tree.c (type_hash_eq): Check for TYPE_NAME of two colliding
         tentative struct/union types.

Index: tree.c
===================================================================
*** tree.c      (revision 119530)
--- tree.c      (working copy)
*************** type_hash_eq (const void *va, const void
*** 4214,4219 ****
--- 4214,4221 ----
       case RECORD_TYPE:
       case UNION_TYPE:
       case QUAL_UNION_TYPE:
+       if (!TYPE_FIELDS (a->type) && !TYPE_FIELDS (b->type))
+       return TYPE_NAME (a->type) == TYPE_NAME (b->type);
         return (TYPE_FIELDS (a->type) == TYPE_FIELDS (b->type)
               || (TYPE_FIELDS (a->type)
                   && TREE_CODE (TYPE_FIELDS (a->type)) == TREE_LIST



More information about the Gcc-patches mailing list