Commit 2e2da467 by Ziemowit Laski Committed by Ziemowit Laski

typeck.c (build_c_cast): Preserve the cast if casting to and from an Objective-C type.

[gcc/cp/ChangeLog]
2004-09-09  Ziemowit Laski  <zlaski@apple.com>

        * typeck.c (build_c_cast): Preserve the cast if casting
        to and from an Objective-C type.

From-SVN: r87277
parent 236f9832
2004-09-09 Ziemowit Laski <zlaski@apple.com> 2004-09-09 Ziemowit Laski <zlaski@apple.com>
* typeck.c (build_c_cast): Preserve the cast if casting
to and from an Objective-C type.
2004-09-09 Ziemowit Laski <zlaski@apple.com>
* Make-lang.in (cp/typeck.o): Depend on c-common.h. * Make-lang.in (cp/typeck.o): Depend on c-common.h.
* typeck.c: Include c-common.h. * typeck.c: Include c-common.h.
(comptypes): For RECORD_TYPEs, call objc_comptypes() and (comptypes): For RECORD_TYPEs, call objc_comptypes() and
......
...@@ -4829,6 +4829,13 @@ build_c_cast (tree type, tree expr) ...@@ -4829,6 +4829,13 @@ build_c_cast (tree type, tree expr)
return t; return t;
} }
/* Casts to a (pointer to a) specific ObjC class (or 'id' or
'Class') should always be retained, because this information aids
in method lookup. */
if (objc_is_object_ptr (type)
&& objc_is_object_ptr (TREE_TYPE (expr)))
return build_nop (type, expr);
/* build_c_cast puts on a NOP_EXPR to make the result not an lvalue. /* build_c_cast puts on a NOP_EXPR to make the result not an lvalue.
Strip such NOP_EXPRs if VALUE is being used in non-lvalue context. */ Strip such NOP_EXPRs if VALUE is being used in non-lvalue context. */
if (TREE_CODE (type) != REFERENCE_TYPE if (TREE_CODE (type) != REFERENCE_TYPE
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment