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
This commit is contained in:
Ziemowit Laski 2004-09-10 06:40:15 +00:00 committed by Ziemowit Laski
parent 236f983261
commit 2e2da46727
2 changed files with 12 additions and 0 deletions

View File

@ -1,3 +1,8 @@
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.

View File

@ -4829,6 +4829,13 @@ build_c_cast (tree type, tree expr)
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.
Strip such NOP_EXPRs if VALUE is being used in non-lvalue context. */
if (TREE_CODE (type) != REFERENCE_TYPE