summaryrefslogtreecommitdiffstats
path: root/gcc/cp
diff options
context:
space:
mode:
authordgregor <dgregor@138bc75d-0d04-0410-961f-82ee72b054a4>2008-02-11 18:58:16 +0000
committerdgregor <dgregor@138bc75d-0d04-0410-961f-82ee72b054a4>2008-02-11 18:58:16 +0000
commit3a4dfc3ecdae1ddcbfea062c2ee702ba667a0110 (patch)
treec298948c45413e7898e0f1947f2ba50cfd4b213f /gcc/cp
parente54ec148a35bf5c9ab4bdee714c5cf0fa580b9ca (diff)
downloadppe42-gcc-3a4dfc3ecdae1ddcbfea062c2ee702ba667a0110.tar.gz
ppe42-gcc-3a4dfc3ecdae1ddcbfea062c2ee702ba667a0110.zip
2008-02-11 Douglas Gregor <doug.gregor@gmail.com>
PR c++/35113 * tree.c (cp_build_qualified_type_real): When building a cv-qualified array type, build it as a unique type with build_cplus_array_type_1 and then adopt the unqualified type's main variant. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@132242 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/cp')
-rw-r--r--gcc/cp/ChangeLog8
-rw-r--r--gcc/cp/tree.c66
2 files changed, 34 insertions, 40 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index fe12e56cd26..1e26a168137 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,11 @@
+2008-02-11 Douglas Gregor <doug.gregor@gmail.com>
+
+ PR c++/35113
+ * tree.c (cp_build_qualified_type_real): When building a
+ cv-qualified array type, build it as a unique type with
+ build_cplus_array_type_1 and then adopt the unqualified type's
+ main variant.
+
2008-02-11 Paolo Carlini <pcarlini@suse.de>
PR c++/35077
diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c
index e893442be42..44a2e7899b1 100644
--- a/gcc/cp/tree.c
+++ b/gcc/cp/tree.c
@@ -726,47 +726,33 @@ cp_build_qualified_type_real (tree type,
break;
if (!t)
- {
- tree index_type = TYPE_DOMAIN (type);
- void **e;
- cplus_array_info cai;
- hashval_t hash;
-
- if (cplus_array_htab == NULL)
- cplus_array_htab = htab_create_ggc (61, &cplus_array_hash,
- &cplus_array_compare,
- NULL);
-
- hash = (htab_hash_pointer (element_type)
- ^ htab_hash_pointer (index_type));
- cai.type = element_type;
- cai.domain = index_type;
-
- e = htab_find_slot_with_hash (cplus_array_htab, &cai, hash, INSERT);
- if (*e)
- /* We have found the type: we're done. */
- return (tree) *e;
-
- /* Build a new array type and add it into the table. */
- t = build_variant_type_copy (type);
- TREE_TYPE (t) = element_type;
- *e = t;
+ {
+ t = build_cplus_array_type_1 (element_type, TYPE_DOMAIN (type));
- /* Set the canonical type for this new node. */
- if (TYPE_STRUCTURAL_EQUALITY_P (element_type)
- || (index_type && TYPE_STRUCTURAL_EQUALITY_P (index_type)))
- SET_TYPE_STRUCTURAL_EQUALITY (t);
- else if (TYPE_CANONICAL (element_type) != element_type
- || (index_type
- && TYPE_CANONICAL (index_type) != index_type)
- || TYPE_CANONICAL (type) != type)
- TYPE_CANONICAL (t)
- = build_cplus_array_type
- (TYPE_CANONICAL (element_type),
- index_type? TYPE_CANONICAL (index_type) : index_type);
- else
- TYPE_CANONICAL (t) = t;
- }
+ if (TYPE_MAIN_VARIANT (t) != TYPE_MAIN_VARIANT (type))
+ {
+ /* Set the main variant of the newly-created ARRAY_TYPE
+ (with cv-qualified element type) to the main variant of
+ the unqualified ARRAY_TYPE we started with. */
+ tree last_variant = t;
+ tree m = TYPE_MAIN_VARIANT (type);
+
+ /* Find the last variant on the new ARRAY_TYPEs list of
+ variants, setting the main variant of each of the other
+ types to the main variant of our unqualified
+ ARRAY_TYPE. */
+ while (TYPE_NEXT_VARIANT (last_variant))
+ {
+ TYPE_MAIN_VARIANT (last_variant) = m;
+ last_variant = TYPE_NEXT_VARIANT (last_variant);
+ }
+
+ /* Splice in the newly-created variants. */
+ TYPE_NEXT_VARIANT (last_variant) = TYPE_NEXT_VARIANT (m);
+ TYPE_NEXT_VARIANT (m) = t;
+ TYPE_MAIN_VARIANT (last_variant) = m;
+ }
+ }
/* Even if we already had this variant, we update
TYPE_NEEDS_CONSTRUCTING and TYPE_HAS_NONTRIVIAL_DESTRUCTOR in case
OpenPOWER on IntegriCloud