PATCH: ObjC-specific changes to c-typeck.c

Ziemowit Laski zlaski@apple.com
Tue Aug 24 02:46:00 GMT 2004


On 23 Aug 2004, at 18.05, Zack Weinberg wrote:

> Ziemowit Laski <zlaski@apple.com> writes:
>
>> The current patch contains the mod needed for c-typeck.c.  The problem
>> was that casts to ObjC types (e.g., '(Object <Proto> *)foo') were
>> sometimes getting "optimized away" by build_c_cast().  This led to
>> problems when constructing message expressions (e.g., '[(Object
>> <Proto> *)foo msg]'), where not knowing the user-intended type for the
>> receiver led to incorrect diagnostics, or worse yet, incorrect codegen
>> (if an ABI-incompatible method signature were to be selected).
>
> My knee-jerk reaction is that the type of the underlying DECL should
> be set correctly in the first place, so that the conversion is
> unnecessary.  If for some reason that is impossible, then the
> conversion should not be sent through build_c_cast (since it does not
> have the semantics of a C cast).

Actually, it _does_ have the semantics of a C cast, and gets parsed by 
the
C common code, which is why we end up in build_c_cast (in other words,
I'm not calling build_c_cast() manually here).  The problem is how
ObjC uses the TYPE_MAIN_VARIANT field (and has used it since time 
immemorial).
This should be rewritten in the future, possibly using attributes to 
hang
protocols off of types. :-)  But for the time being, I submit we retain
the hack as is.

> However, there may be some good reason why it has to be done this way.
> I would suggest you get Joseph Myers to look at this; he's more
> familiar with c-typeck.c's intricacies than I am.

Ok; I'll wait for word from him.  Actually, he did approve this work
previously (i.e., prior to the gengtype.c stuff going in), but I don't
know if that approval is still operative. :-)

--Zem
--------------------------------------------------------------
Ziemowit Laski                 1 Infinite Loop, MS 301-2K
Mac OS X Compiler Group        Cupertino, CA USA  95014-2083
Apple Computer, Inc.           +1.408.974.6229  Fax .5477



More information about the Gcc-patches mailing list