summaryrefslogtreecommitdiff
path: root/gcc/objc
diff options
context:
space:
mode:
authornicola <nicola@138bc75d-0d04-0410-961f-82ee72b054a4>2010-09-27 18:04:09 +0000
committernicola <nicola@138bc75d-0d04-0410-961f-82ee72b054a4>2010-09-27 18:04:09 +0000
commit4abfc532e3ffc6353597404a1784013cfbeaef70 (patch)
tree52eceb4b49f0f2845bf998c477ea0bead40db6a6 /gcc/objc
parent046cb05c5a1580ca187222781e6736aacf247173 (diff)
downloadgcc-4abfc532e3ffc6353597404a1784013cfbeaef70.tar.gz
In gcc/:
2010-09-27 Nicola Pero <nicola.pero@meta-innovation.com> Merge from 'apple/trunk' branch on FSF servers. Removed small change in build_conditional_expr that had been added when fixing PR objc/27377 and which did the same check in a less complete way. 2005-12-15 Fariborz Jahanian <fjahanian@apple.com> Radar 4229905 * c-typeck.c (build_conditional_expr): Call objc_have_common_type when looking for objective-c common pointer types. 2005-06-22 Ziemowit Laski <zlaski@apple.com> Radar 4154928 * c-typeck.c (build_conditional_expr): For two ObjC pointer types, use their ObjC common type. In gcc/c-family: 2010-09-27 Nicola Pero <nicola.pero@meta-innovation.com> Merge from 'apple/trunk' branch on FSF servers. 2005-12-15 Fariborz Jahanian <fjahanian@apple.com> Radar 4229905 * c-common.h (objc_have_common_type): New declaration. * stub-objc.c (objc_have_common_type): New stub. 2005-06-22 Ziemowit Laski <zlaski@apple.com> Radar 4154928 * c-common.h (objc_common_type): New prototype. * stub-objc.c (objc_common_type): New stub. In gcc/objc/: 2010-09-27 Nicola Pero <nicola.pero@meta-innovation.com> Merge from 'apple/trunk' branch on FSF servers. 2005-12-15 Fariborz Jahanian <fjahanian@apple.com> Radar 4229905 * objc-act.c (objc_have_common_types): New function. 2005-06-22 Ziemowit Laski <zlaski@apple.com> Radar 4154928 * objc-act.c (objc_common_type): New function. In gcc/cp/: 2010-09-27 Nicola Pero <nicola.pero@meta-innovation.com> Merge from apple/trunk branch on FSF servers: 2005-12-15 Fariborz Jahanian <fjahanian@apple.com> Radar 4229905 * typeck.c (composite_pointer_type): Call objc_have_common_type when comparing two objective-c pointer types. 2005-06-22 Ziemowit Laski <zlaski@apple.com> Radar 4154928 * call.c (standard_conversion): Allow for a pointer conversion between any two ObjC pointer types. * typeck.c (composite_pointer_type): Determine common type for two ObjC pointer types. In gcc/testsuite/: 2010-09-27 Nicola Pero <nicola.pero@meta-innovation.com> Merge from 'apple/trunk' branch on FSF servers. Renamed const-str-12.m to constr-str-12b.m to avoid conflicts. 2005-12-15 Fariborz Jahanian <fjahanian@apple.com> Radar 4229905 * obj-c++.dg/warn5.mm: New 2005-06-22 Ziemowit Laski <zlaski@apple.com> Radar 4154928 * obj-c++.dg/const-str-12.mm: New. * objc.dg/const-str-12.m: New. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@164655 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/objc')
-rw-r--r--gcc/objc/ChangeLog14
-rw-r--r--gcc/objc/objc-act.c51
2 files changed, 65 insertions, 0 deletions
diff --git a/gcc/objc/ChangeLog b/gcc/objc/ChangeLog
index 9a2e46b96ab..8e70e208bcd 100644
--- a/gcc/objc/ChangeLog
+++ b/gcc/objc/ChangeLog
@@ -1,3 +1,17 @@
+2010-09-27 Nicola Pero <nicola.pero@meta-innovation.com>
+
+ Merge from 'apple/trunk' branch on FSF servers.
+
+ 2005-12-15 Fariborz Jahanian <fjahanian@apple.com>
+
+ Radar 4229905
+ * objc-act.c (objc_have_common_types): New function.
+
+ 2005-06-22 Ziemowit Laski <zlaski@apple.com>
+
+ Radar 4154928
+ * objc-act.c (objc_common_type): New function.
+
2010-09-27 Richard Guenther <rguenther@suse.de>
* objc-act.c (objc_get_class_reference): Use CP_TYPE_CONTEXT.
diff --git a/gcc/objc/objc-act.c b/gcc/objc/objc-act.c
index e4483da7adb..5d76596479c 100644
--- a/gcc/objc/objc-act.c
+++ b/gcc/objc/objc-act.c
@@ -1100,6 +1100,35 @@ objc_compare_protocols (tree lcls, tree ltyp, tree rcls, tree rtyp, bool warn)
return have_lproto || (rcls != NULL_TREE);
}
+/* Given two types TYPE1 and TYPE2, return their least common ancestor.
+ Both TYPE1 and TYPE2 must be pointers, and already determined to be
+ compatible by objc_compare_types() below. */
+
+tree
+objc_common_type (tree type1, tree type2)
+{
+ tree inner1 = TREE_TYPE (type1), inner2 = TREE_TYPE (type2);
+
+ while (POINTER_TYPE_P (inner1))
+ {
+ inner1 = TREE_TYPE (inner1);
+ inner2 = TREE_TYPE (inner2);
+ }
+
+ /* If one type is derived from another, return the base type. */
+ if (DERIVED_FROM_P (inner1, inner2))
+ return type1;
+ else if (DERIVED_FROM_P (inner2, inner1))
+ return type2;
+
+ /* If both types are 'Class', return 'Class'. */
+ if (objc_is_class_id (inner1) && objc_is_class_id (inner2))
+ return objc_class_type;
+
+ /* Otherwise, return 'id'. */
+ return objc_object_type;
+}
+
/* Determine if it is permissible to assign (if ARGNO is greater than -3)
an instance of RTYP to an instance of LTYP or to compare the two
(if ARGNO is equal to -3), per ObjC type system rules. Before
@@ -1273,6 +1302,28 @@ objc_compare_types (tree ltyp, tree rtyp, int argno, tree callee)
return true;
}
+/* This routine is similar to objc_compare_types except that function-pointers are
+ excluded. This is because, caller assumes that common types are of (id, Object*)
+ variety and calls objc_common_type to obtain a common type. There is no commonolty
+ between two function-pointers in this regard. */
+
+bool
+objc_have_common_type (tree ltyp, tree rtyp, int argno, tree callee)
+{
+ if (objc_compare_types (ltyp, rtyp, argno, callee))
+ {
+ /* exclude function-pointer types. */
+ do
+ {
+ ltyp = TREE_TYPE (ltyp); /* Remove indirections. */
+ rtyp = TREE_TYPE (rtyp);
+ }
+ while (POINTER_TYPE_P (ltyp) && POINTER_TYPE_P (rtyp));
+ return !(TREE_CODE (ltyp) == FUNCTION_TYPE && TREE_CODE (rtyp) == FUNCTION_TYPE);
+ }
+ return false;
+}
+
/* Check if LTYP and RTYP have the same type qualifiers. If either type
lives in the volatilized hash table, ignore the 'volatile' bit when
making the comparison. */