summaryrefslogtreecommitdiff
path: root/gcc/tree.c
diff options
context:
space:
mode:
authorRichard Guenther <rguenther@suse.de>2009-09-06 16:49:48 +0000
committerRichard Biener <rguenth@gcc.gnu.org>2009-09-06 16:49:48 +0000
commit3797a0ff2f3da43cef2c13b2b3fad2695cd7cf02 (patch)
treea72925e0455fa9de377a22b3f81c4b9a32bdf2fd /gcc/tree.c
parent3c45b96b27d5be00740b13ad80ae6c6be9c96dbc (diff)
downloadgcc-3797a0ff2f3da43cef2c13b2b3fad2695cd7cf02.tar.gz
re PR c++/41144 (ice for legal code with -O2 in get_alias_set)
2009-09-06 Richard Guenther <rguenther@suse.de> PR middle-end/41144 * tree.c (build_array_type): Do not record types marked with structural equality in the canonical type hashtable. * g++.dg/torture/pr41144.C: New testcase. From-SVN: r151461
Diffstat (limited to 'gcc/tree.c')
-rw-r--r--gcc/tree.c37
1 files changed, 11 insertions, 26 deletions
diff --git a/gcc/tree.c b/gcc/tree.c
index 1db7d0a86c3..a036439cc3f 100644
--- a/gcc/tree.c
+++ b/gcc/tree.c
@@ -6906,44 +6906,29 @@ build_array_type (tree elt_type, tree index_type)
t = make_node (ARRAY_TYPE);
TREE_TYPE (t) = elt_type;
TYPE_DOMAIN (t) = index_type;
-
- if (index_type == 0)
- {
- tree save = t;
- hashcode = iterative_hash_object (TYPE_HASH (elt_type), hashcode);
- t = type_hash_canon (hashcode, t);
- if (save == t)
- layout_type (t);
-
- if (TYPE_CANONICAL (t) == t)
- {
- if (TYPE_STRUCTURAL_EQUALITY_P (elt_type))
- SET_TYPE_STRUCTURAL_EQUALITY (t);
- else if (TYPE_CANONICAL (elt_type) != elt_type)
- TYPE_CANONICAL (t)
- = build_array_type (TYPE_CANONICAL (elt_type), index_type);
- }
+ layout_type (t);
- return t;
- }
+ /* If the element type is incomplete at this point we get marked for
+ structural equality. Do not record these types in the canonical
+ type hashtable. */
+ if (TYPE_STRUCTURAL_EQUALITY_P (t))
+ return t;
hashcode = iterative_hash_object (TYPE_HASH (elt_type), hashcode);
- hashcode = iterative_hash_object (TYPE_HASH (index_type), hashcode);
+ if (index_type)
+ hashcode = iterative_hash_object (TYPE_HASH (index_type), hashcode);
t = type_hash_canon (hashcode, t);
- if (!COMPLETE_TYPE_P (t))
- layout_type (t);
-
if (TYPE_CANONICAL (t) == t)
{
if (TYPE_STRUCTURAL_EQUALITY_P (elt_type)
- || TYPE_STRUCTURAL_EQUALITY_P (index_type))
+ || (index_type && TYPE_STRUCTURAL_EQUALITY_P (index_type)))
SET_TYPE_STRUCTURAL_EQUALITY (t);
else if (TYPE_CANONICAL (elt_type) != elt_type
- || TYPE_CANONICAL (index_type) != index_type)
+ || (index_type && TYPE_CANONICAL (index_type) != index_type))
TYPE_CANONICAL (t)
= build_array_type (TYPE_CANONICAL (elt_type),
- TYPE_CANONICAL (index_type));
+ index_type ? TYPE_CANONICAL (index_type) : NULL);
}
return t;