This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[objc] Patch for PR18408 (Was: Re: Objective-C bugs and GCC releases)
- From: Alexander Malmberg <alexander at malmberg dot org>
- To: Richard Henderson <rth at redhat dot com>
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Tue, 25 Jan 2005 02:41:10 +0100
- Subject: [objc] Patch for PR18408 (Was: Re: Objective-C bugs and GCC releases)
- References: <20050124224245.24868.qmail@web41623.mail.yahoo.com> <Pine.LNX.4.60.0501241747060.27603@dberlin.org> <90688240-6E5E-11D9-9B1D-000393D76DAA@apple.com> <20050124234328.GA29804@redhat.com>
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;