]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
PR middle-end/54860 - Make sure attributes hash table is created
authorDodji Seketeli <dodji@redhat.com>
Wed, 10 Oct 2012 10:25:03 +0000 (10:25 +0000)
committerDodji Seketeli <dodji@gcc.gnu.org>
Wed, 10 Oct 2012 10:25:03 +0000 (12:25 +0200)
On targets cris-elf, alpha and sparc (for instance) it can happen that
the attribute_tables variable is empty for fortran.  Thus
register_scoped_attributes (called by init_attributes) won't call
register_scoped_attributes, so the hash table member of
scoped_attributes is not created.

Later when we try to e.g, lookup an attribute by calling
lookup_scoped_attribute_spec, that NULL member hash table comes to
byte us as htab_find_with_hash crashes.

This patch fixes this by ensuring in register_scoped_attributes that
the hash table is created.

Tested on cris-elf, x86_64-unknown-linux-gnu against trunk and some
commenters on the bug bootstrapped it on alpha and sparc.

gcc/

* attribs.c (register_scoped_attributes): Ensure the attribute
hash table is created.

From-SVN: r192301

gcc/ChangeLog
gcc/attribs.c

index 98407361bc708f46a176336665f3cf82e04efd76..ab78559836e44bb182adee2facddf673d02d5587 100644 (file)
@@ -1,3 +1,9 @@
+2012-10-10  Dodji Seketeli  <dodji@redhat.com>
+
+       PR middle-end/54860 - Make sure attributes hash table is created
+       * attribs.c (register_scoped_attributes): Ensure the attribute
+       hash table is created.
+
 2012-10-10  Ganesh Gopalasubramanian  <Ganesh.Gopalasubramanian@amd.com>
 
        PR target/51109
index b330f27d89d2ab9c8db9dfa92bad89a7c1fffddd..d167c1f6e13fe550e8d9a932e44792bbfde19e2a 100644 (file)
@@ -146,7 +146,8 @@ register_scoped_attributes (const struct attribute_spec * attributes,
       memset (&sa, 0, sizeof (sa));
       sa.ns = ns;
       sa.attributes = VEC_alloc (attribute_spec, heap, 64);
-      result = VEC_safe_push (scoped_attributes, heap, attributes_table, sa);      
+      result = VEC_safe_push (scoped_attributes, heap, attributes_table, sa);
+      result->attribute_hash = htab_create (200, hash_attr, eq_attr, NULL);
     }
 
   /* Really add the attributes to their namespace now.  */
@@ -284,8 +285,7 @@ register_scoped_attribute (const struct attribute_spec *attr,
 
   gcc_assert (attr != NULL && name_space != NULL);
 
-  if (name_space->attribute_hash == NULL)
-   name_space->attribute_hash = htab_create (200, hash_attr, eq_attr, NULL);
+  gcc_assert (name_space->attribute_hash != NULL);
 
   str.str = attr->name;
   str.length = strlen (str.str);