This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
[Objective-C PATCH] Canonical types (3/3)
- From: "Doug Gregor" <doug dot gregor at gmail dot com>
- To: gcc at gcc dot gnu dot org, "GCC Patches" <gcc-patches at gcc dot gnu dot org>
- Date: Tue, 28 Nov 2006 10:56:12 -0500
- Subject: [Objective-C PATCH] Canonical types (3/3)
This patch introduces canonical types into GCC. See the first part of
this patch for a complete explanation.
This is part three of three, containing changes to the Objective-C
(and, thus, Objective-C++) front end.
Okay for mainline?
Cheers,
Doug Gregor
Open Systems Lab @ Indiana University
2006-11-28 Douglas Gregor <doug.gregor@gmail.com>
* objc-act.c (objc_build_volatilized_type): Keep track of
canonical types.
(objc_get_protocol_qualified_type): Ditto.
Index: objc-act.c
===================================================================
--- objc-act.c (revision 119271)
+++ objc-act.c (working copy)
@@ -908,6 +908,11 @@ objc_build_volatilized_type (tree type)
t = build_variant_type_copy (type);
TYPE_VOLATILE (t) = 1;
+ /* Set up the canonical type information. */
+ if (TYPE_CANONICAL (type) != type)
+ TYPE_CANONICAL (t) = objc_build_volatilized_type (TYPE_CANONICAL (type));
+ TYPE_STRUCTURAL_EQUALITY (t) = TYPE_STRUCTURAL_EQUALITY (type);
+
return t;
}
@@ -1364,13 +1369,26 @@ objc_get_protocol_qualified_type (tree i
if (protocols)
{
- type = build_variant_type_copy (type);
+ tree orig_type = type;
+ type = build_variant_type_copy (orig_type);
+
+ /* Set up the canonical type information. */
+ TYPE_CANONICAL (type) = TYPE_CANONICAL (orig_type);
+ TYPE_STRUCTURAL_EQUALITY (type) = TYPE_STRUCTURAL_EQUALITY (orig_type);
/* For pointers (i.e., 'id' or 'Class'), attach the protocol(s)
to the pointee. */
if (is_ptr)
{
- TREE_TYPE (type) = build_variant_type_copy (TREE_TYPE (type));
+ tree orig_pointee_type = TREE_TYPE (type);
+ TREE_TYPE (type) = build_variant_type_copy (orig_pointee_type);
+
+ /* Set up the canonical type information. */
+ TYPE_CANONICAL (type) =
+ TYPE_CANONICAL (TYPE_POINTER_TO (orig_pointee_type));
+ TYPE_STRUCTURAL_EQUALITY (type) =
+ TYPE_STRUCTURAL_EQUALITY (orig_pointee_type);
+
TYPE_POINTER_TO (TREE_TYPE (type)) = type;
type = TREE_TYPE (type);
}