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]

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


Ziemowit Laski wrote:
On 24 Jan 2005, at 17.41, Alexander Malmberg wrote:
objc/ChangeLog:
2005-01-25  Alexander Malmberg  <alexander@malmberg.org>

* objc-act.c (objc_types_compatible_p): New function.

Also #include "langhooks-def.h"; please also update Make-lang.in.

objc/Make-lang.in already has:


objc/objc-act.o : objc/objc-act.c \
[snip]
   $(LANGHOOKS_DEF_H) $(HASHTAB_H) c-pragma.h gt-objc-objc-act.h
   ^^^^^^^^^^^^^^^^^^

so if I understand this correctly, I don't need to add anything here.

[snip]
+    {
+      return c_types_compatible_p (type1, type2);


If you could put in #ifdef OBJCPLUS for cxx_types_compatible_p() (or whatever it's called), that would be great.

cxx_types_compatible_p is right. Done, although I haven't tested the obj-c++ part.


[snip]
Also, please include the comp-types-7.m test case.

I'm assuming you mean Pinski's test case from the PR.


> If you get a clean
bootstrap with no regressions, this patch is fine by me. Thanks.

Bootstrapped (c,objc) on i686-pc-linux-gnu. 'make check-objc' has no new failures, and I've confirmed that comp-types-7.m fails with an unpatched compiler.


(Pinski: If this is ok, could you commit it for me?)

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.

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

* objc.dg/comp-types-7.m: New.

- 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 02:36:38 -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,27 @@
   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
+    {
+#ifdef OBJCPLUS
+      return cxx_types_compatible_p (type1, type2);
+#else
+      return c_types_compatible_p (type1, type2);
+#endif
+    }
+}
+
+
 /* 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 02:36:38 -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 02:36:38 -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;
/* { dg-do compile } */

@interface List
{
@public
  int firstLink;
}
@end

@interface ListIndex_linked
{
@public
  List *collection;
  int link;
}
@end

@interface List_linked: List
@end

@implementation List
@end

@implementation ListIndex_linked
- next
{
   link = ((List_linked*)collection)->firstLink;
}
@end

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