aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorZiemowit Laski <zlaski@apple.com>2004-09-10 06:40:15 +0000
committerZiemowit Laski <zlaski@gcc.gnu.org>2004-09-10 06:40:15 +0000
commit2e2da46727a4b1414d5f2f8d2a016a8609268abe (patch)
treef133ff22c97a48897d90f14ae140438988d45677 /gcc
parent236f983261dd0460975b89dc232b8fac6080519d (diff)
downloadgcc-2e2da46727a4b1414d5f2f8d2a016a8609268abe.zip
gcc-2e2da46727a4b1414d5f2f8d2a016a8609268abe.tar.gz
gcc-2e2da46727a4b1414d5f2f8d2a016a8609268abe.tar.bz2
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
Diffstat (limited to 'gcc')
-rw-r--r--gcc/cp/ChangeLog5
-rw-r--r--gcc/cp/typeck.c7
2 files changed, 12 insertions, 0 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 43c58aa..08b32a2 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,5 +1,10 @@
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.
* typeck.c: Include c-common.h.
(comptypes): For RECORD_TYPEs, call objc_comptypes() and
diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c
index 94e903d..f4d1679 100644
--- a/gcc/cp/typeck.c
+++ b/gcc/cp/typeck.c
@@ -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