The NeXT^wApple runtime now has the same problem which the GNU runtime
had for a while on the objc-improvements branch, see PR 11754, in that
cascading message calls would call the first message twice. This
patch fixes this regression on the mainline by doing the same thing for
the next runtime as the GNU runtime, by wrapping a SAVE_EXPR around the
call. I just moved the save_expr to the common part of the code before
the check of the next runtime or the GNU runtime.
OK? Built objc and had no regressions.
Thanks,
Andrew Pinski
ChangeLog:
* objc-act.c (build_objc_method_call): Save the lookup_object
so we do not call it twice.
PATCH:
Index: objc-act.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/objc/objc-act.c,v
retrieving revision 1.226
diff -u -p -r1.226 objc-act.c
--- objc-act.c 23 Jun 2004 00:26:01 -0000 1.226
+++ objc-act.c 24 Jun 2004 22:29:11 -0000
@@ -5869,6 +5869,9 @@ build_objc_method_call (int super_flag,
tree method, t;
lookup_object = build_c_cast (rcv_p, lookup_object);
+
+ /* Use SAVE_EXPR to avoid evaluating the receiver twice. */
+ lookup_object = save_expr (lookup_object);
if (flag_next_runtime)
{
@@ -5895,9 +5898,8 @@ build_objc_method_call (int super_flag,
tree object;
/* First, call the lookup function to get a pointer to the
method,
- then cast the pointer, then call it with the method arguments.
- Use SAVE_EXPR to avoid evaluating the receiver twice. */
- lookup_object = save_expr (lookup_object);
+ then cast the pointer, then call it with the method arguments. */
+
object = (super_flag ? self_decl : lookup_object);
t = tree_cons (NULL_TREE, selector, NULL_TREE);