Unreviewed patch [was : PATCH: Protocol Warning]
Devang Patel
dpatel@apple.com
Tue Aug 20 11:17:00 GMT 2002
On Tuesday, August 20, 2002, at 09:45 AM, Jason Merrill wrote:
> This seems harmless to me, but I'm curious as to how a type with a
> different TYPE_CONTEXT can have the same TYPE_MAIN_VARIANT.
In Objective-C, a type can be qualified for a protocol. This permits the
compiler to test for a type based on conformance to a protocol.
Objective-C front end uses macro TYPE_PROTOCOL_LIST to keep list
of qualified protocols.
Here is relevant code snippet ...
objc-act.h:106:#define TYPE_PROTOCOL_LIST(TYPE) ((TYPE)->type.context)
objc-act.h:279 #define IS_PROTOCOL_QUALIFIED_ID(TYPE) \
objc-act.h:280 (IS_ID (TYPE) && TYPE_PROTOCOL_LIST (TYPE))
And from objc-act.c
830 /* This clause creates a new pointer type that is qualified
with
831 the protocol specification...this info is used later to do
more
832 elaborate type checking. */
833
834 if (protocols)
835 {
836 tree t, m = TYPE_MAIN_VARIANT (type);
837
838 t = copy_node (type);
839 TYPE_BINFO (t) = make_tree_vec (2);
840
841 /* Add this type to the chain of variants of TYPE. */
842 TYPE_NEXT_VARIANT (t) = TYPE_NEXT_VARIANT (m);
843 TYPE_NEXT_VARIANT (m) = t;
844
845 /* Look up protocols...and install in lang specific list
*/
846 TYPE_PROTOCOL_LIST (t) = lookup_and_install_protocols
(protocols);
847
848 /* This forces a new pointer type to be created later
849 (in build_pointer_type)...so that the new template
850 we just created will actually be used...what a hack!
*/
851 if (TYPE_POINTER_TO (t))
852 TYPE_POINTER_TO (t) = NULL_TREE;
853
854 type = t;
855 }
-Devang
More information about the Gcc-patches
mailing list