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]

[objc] Patch for PR18408 (Was: Re: Objective-C bugs and GCC releases)


Richard Henderson wrote:
> I suspect that only viable fix is to write your own types_compatible_p
> hook that doesn't have all of the extra semantics that you want for
> comptypes in the front end.  This will prevent various cast operations
> from being elided during gimplification, which means that all the sanity
> checks will come out ok, and the optimizers won't barf on you.

I've attached a patch that does essentially this. It uses lhd_types_compatible_p for obj-c types and c_types_compatible_p for everything else. 'make check-objc' reports no new failures, GNUstep compiles, and no new failures in the GNUstep testsuite. A simpler patch that always uses lhd_types_compatible_p seems to work, too. All testing on i686-pc-linux-gnu. Haven't had time to bootstrap yet.

objc/ChangeLog:
2005-01-25  Alexander Malmberg  <alexander@malmberg.org>

	* objc-act.c (objc_types_compatible_p): New function.
	* objc-act.h (objc_types_compatible_p): Declare.
	* objc-lang.c (LANG_HOOKS_TYPES_COMPATIBLE_P): Define.

- Alexander Malmberg
Index: gcc/objc/objc-act.c
===================================================================
RCS file: /cvsroot/gcc/gcc/gcc/objc/objc-act.c,v
retrieving revision 1.262
diff -u -r1.262 objc-act.c
--- gcc/objc/objc-act.c	16 Jan 2005 08:13:14 -0000	1.262
+++ gcc/objc/objc-act.c	25 Jan 2005 01:20:07 -0000
@@ -73,6 +73,7 @@
 #include "tree-iterator.h"
 #include "libfuncs.h"
 #include "hashtab.h"
+#include "langhooks-def.h"
 
 #define OBJC_VOID_AT_END	void_list_node
 
@@ -836,6 +837,23 @@
   return OBJC_TYPE_NAME (type) == objc_class_id;
 }
 
+
+int
+objc_types_compatible_p (tree type1, tree type2)
+{
+
+  if (objc_is_object_ptr (type1) || objc_is_object_ptr (type2)
+      || objc_is_class_name (type1) || objc_is_class_name (type2))
+    {
+      return lhd_types_compatible_p (type1, type2);
+    }
+  else
+    {
+      return c_types_compatible_p (type1, type2);
+    }
+}
+
+
 /* Return 1 if LHS and RHS are compatible types for assignment or
    various other operations.  Return 0 if they are incompatible, and
    return -1 if we choose to not decide (because the types are really
Index: gcc/objc/objc-act.h
===================================================================
RCS file: /cvsroot/gcc/gcc/gcc/objc/objc-act.h,v
retrieving revision 1.33
diff -u -r1.33 objc-act.h
--- gcc/objc/objc-act.h	16 Dec 2004 01:10:38 -0000	1.33
+++ gcc/objc/objc-act.h	25 Jan 2005 01:20:07 -0000
@@ -28,6 +28,7 @@
 const char *objc_printable_name (tree, int);
 void objc_finish_file (void);
 tree objc_fold_obj_type_ref (tree, tree);
+int objc_types_compatible_p (tree, tree);
 
 /* NB: The remaining public functions are prototyped in c-common.h, for the
    benefit of stub-objc.c and objc-act.c.  */
Index: gcc/objc/objc-lang.c
===================================================================
RCS file: /cvsroot/gcc/gcc/gcc/objc/objc-lang.c,v
retrieving revision 1.52
diff -u -r1.52 objc-lang.c
--- gcc/objc/objc-lang.c	17 Sep 2004 21:55:02 -0000	1.52
+++ gcc/objc/objc-lang.c	25 Jan 2005 01:20:07 -0000
@@ -45,6 +45,8 @@
 #define LANG_HOOKS_INIT objc_init
 #undef LANG_HOOKS_DECL_PRINTABLE_NAME
 #define LANG_HOOKS_DECL_PRINTABLE_NAME objc_printable_name
+#undef LANG_HOOKS_TYPES_COMPATIBLE_P
+#define LANG_HOOKS_TYPES_COMPATIBLE_P objc_types_compatible_p
 
 /* Each front end provides its own lang hook initializer.  */
 const struct lang_hooks lang_hooks = LANG_HOOKS_INITIALIZER;

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