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: Robustify cp_fold_obj_type_ref() for ObjC++ use - PART I


This is the ObjC part. I'm putting the lang hook in ObjC instead of (only) ObjC++
just in case we may need to access it from plain C in the future.


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

        * objc-act.c (objc_fold_objc_type_ref): New function.
        * objc-act.h (objc_fold_objc_type_ref): New prototype.

Index: gcc/objc/objc-act.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/objc/objc-act.c,v
retrieving revision 1.245
diff -u -3 -p -r1.245 objc-act.c
--- gcc/objc/objc-act.c 9 Sep 2004 01:19:15 -0000       1.245
+++ gcc/objc/objc-act.c 22 Sep 2004 00:25:04 -0000
@@ -7530,6 +7530,28 @@ comp_proto_with_proto (tree proto1, tree
   return (!type1 && !type2);
 }

+/* Fold an OBJ_TYPE_REF expression for ObjC method dispatches, where
+ this occurs. ObjC method dispatches are _not_ like C++ virtual
+ member function dispatches, and we account for the difference here. */
+tree
+objc_fold_obj_type_ref (tree ref, tree known_type)
+{
+#ifdef OBJCPLUS
+ tree v = BINFO_VIRTUALS (TYPE_BINFO (known_type));
+
+ /* If the receiver does not have virtual member functions, there
+ is nothing we can (or need to) do here. */
+ if (!v)
+ return NULL_TREE;
+
+ /* Let C++ handle C++ virtual functions. */
+ return cp_fold_obj_type_ref (ref, known_type);
+#else
+ /* For plain ObjC, we currently do not need to do anything. */
+ return NULL_TREE;
+#endif
+}
+
static void
objc_start_function (tree name, tree type, tree attrs,
#ifdef OBJCPLUS
Index: gcc/objc/objc-act.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/objc/objc-act.h,v
retrieving revision 1.30
diff -u -3 -p -r1.30 objc-act.h
--- gcc/objc/objc-act.h 8 Sep 2004 00:49:44 -0000 1.30
+++ gcc/objc/objc-act.h 22 Sep 2004 00:25:04 -0000
@@ -27,6 +27,7 @@ Boston, MA 02111-1307, USA. */
bool objc_init (void);
const char *objc_printable_name (tree, int);
void objc_finish_file (void);
+tree objc_fold_obj_type_ref (tree, tree);


/* NB: The remaining public functions are prototyped in c-common.h, for the
benefit of stub-objc.c and objc-act.c. */


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