This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

PATCH: Teach C++'s comptypes() about ObjC++


Here, we call objc_comptypes() from within the bowels of comptypes(), so that
ObjC types get compared properly. If either of the types being compared is not
an ObjC type, objc_comptypes() returns -1 and the code falls through to C++
semantics. The stub-objc.c version of objc_comptypes() always returns -1.


OK for mainline? Perhaps in this case I _should_ add a c_dialect_objc() check,
to avoid needlessly assigning to retval in the pure C++ case? :-)


[gcc/cp/ChangeLog]
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
        return the result if nonnegative.

Index: gcc/cp/Make-lang.in
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/Make-lang.in,v
retrieving revision 1.193
diff -u -3 -p -r1.193 Make-lang.in
--- gcc/cp/Make-lang.in 9 Sep 2004 01:49:00 -0000 1.193
+++ gcc/cp/Make-lang.in 9 Sep 2004 19:13:23 -0000
@@ -240,7 +240,7 @@ cp/cp-objcp-common.o : cp/cp-objcp-commo
cp/typeck2.o: cp/typeck2.c $(CXX_TREE_H) $(TM_H) flags.h toplev.h output.h $(TM_P_H) \
diagnostic.h gt-cp-typeck2.h
cp/typeck.o: cp/typeck.c $(CXX_TREE_H) $(TM_H) flags.h $(RTL_H) $(EXPR_H) toplev.h \
- diagnostic.h convert.h
+ diagnostic.h convert.h c-common.h
cp/class.o: cp/class.c $(CXX_TREE_H) $(TM_H) flags.h toplev.h $(RTL_H) $(TARGET_H) convert.h
cp/call.o: cp/call.c $(CXX_TREE_H) $(TM_H) flags.h toplev.h $(RTL_H) $(EXPR_H) \
diagnostic.h intl.h gt-cp-call.h convert.h target.h
Index: gcc/cp/typeck.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/typeck.c,v
retrieving revision 1.572
diff -u -3 -p -r1.572 typeck.c
--- gcc/cp/typeck.c 30 Aug 2004 18:59:12 -0000 1.572
+++ gcc/cp/typeck.c 9 Sep 2004 19:13:23 -0000
@@ -41,6 +41,7 @@ Boston, MA 02111-1307, USA. */
#include "diagnostic.h"
#include "target.h"
#include "convert.h"
+#include "c-common.h"


static tree convert_for_assignment (tree, tree, const char *, tree, int);
static tree cp_pointer_int_sum (enum tree_code, tree, tree);
@@ -919,6 +920,8 @@ comp_array_types (tree t1, tree t2, bool
bool
comptypes (tree t1, tree t2, int strict)
{
+ int retval;
+
if (t1 == t2)
return true;


@@ -1002,6 +1005,11 @@ comptypes (tree t1, tree t2, int strict)
       /* Fall through.  */

     case RECORD_TYPE:
+      /* We may be dealing with Objective-C instances...  */
+      if ((retval = objc_comptypes (t1, t2, 0) >= 0))
+         return retval;
+      /* ...but fall through if we are not.  */
+
     case UNION_TYPE:
       if (TYPE_TEMPLATE_INFO (t1) && TYPE_TEMPLATE_INFO (t2)
          && (TYPE_TI_TEMPLATE (t1) == TYPE_TI_TEMPLATE (t2)

--------------------------------------------------------------
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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]