From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 11124 invoked by alias); 21 Dec 2001 20:04:08 -0000 Mailing-List: contact gdb-patches-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sources.redhat.com Received: (qmail 11102 invoked from network); 21 Dec 2001 20:04:06 -0000 Received: from unknown (HELO zwingli.cygnus.com) (208.245.165.35) by sources.redhat.com with SMTP; 21 Dec 2001 20:04:06 -0000 Received: by zwingli.cygnus.com (Postfix, from userid 442) id 9282E5E9D8; Fri, 21 Dec 2001 15:05:26 -0500 (EST) To: Daniel Jacobowitz Cc: gdb-patches@sources.redhat.com Subject: Re: [RFA] Allow casting of object pointers for method calls References: <20011203104217.A13460@nevyn.them.org> From: Jim Blandy Date: Fri, 21 Dec 2001 12:04:00 -0000 In-Reply-To: Daniel Jacobowitz's message of Mon, 3 Dec 2001 10:42:17 -0500 Message-ID: X-Mailer: Gnus v5.3/Emacs 19.34 X-SW-Source: 2001-12/txt/msg00564.txt.bz2 Please commit this. Thanks! Daniel Jacobowitz writes: > > I'd like to commit this. > > >From the comment on value_virtual_fn_field: > VALUEP is a pointer to a pointer to a value, holding the object > whose virtual function we want to invoke. If the ABI requires a > virtual function's caller to adjust the `this' pointer by an amount > retrieved from the vtable before invoking the function (i.e., we're > not using "vtable thunks" to do the adjustment automatically), then > this function may set *VALUEP to point to a new object with an > appropriately tweaked address. > > find_overload_match went out of its way to prevent this from working. The > cast at the end is unpleasant but, as far as I can see, correct; > value_find_oload_method_list tends to dereference pointers, and if we don't > return this rather than *this things die. > > With this patch, all virtfunc tests other than: > XFAIL: gdb.c++/virtfunc.exp: print pEe->D::vg() > > pass using g++ 2.95. No other regressions. I'll submit a separate patch to > remove their XFAILs. This is also necessary for my g++ 3.0 support stuff, > which is pretty trivial after Jason's gcc work and this values patchs. > > Anyone, comments? I think the hack is (for now at least, maybe with a > FIXME) tolerable. > > -- > Daniel Jacobowitz Carnegie Mellon University > MontaVista Software Debian GNU/Linux Developer > > 2001-12-03 Daniel Jacobowitz > > * valops.c (find_overload_match): Accept obj as a > reference parameter. Update it before returning. > * value.h (find_overload_match): Update prototype. > * eval.c (evaluate_subexp_standard): Pass object to > find_overload_match by reference. > > Index: eval.c > =================================================================== > RCS file: /cvs/src/src/gdb/eval.c,v > retrieving revision 1.16 > diff -u -p -r1.16 eval.c > --- eval.c 2001/11/12 21:20:18 1.16 > +++ eval.c 2001/12/03 15:27:58 > @@ -845,7 +845,7 @@ evaluate_subexp_standard (struct type *e > > (void) find_overload_match (arg_types, nargs, tstr, > 1 /* method */ , 0 /* strict match */ , > - arg2 /* the object */ , NULL, > + &arg2 /* the object */ , NULL, > &valp, NULL, &static_memfuncp); > > > Index: valops.c > =================================================================== > RCS file: /cvs/src/src/gdb/valops.c,v > retrieving revision 1.41 > diff -u -p -r1.41 valops.c > --- valops.c 2001/11/13 16:44:13 1.41 > +++ valops.c 2001/12/03 15:27:58 > @@ -2618,12 +2618,13 @@ value_find_oload_method_list (value_ptr > > int > find_overload_match (struct type **arg_types, int nargs, char *name, int method, > - int lax, value_ptr obj, struct symbol *fsym, > + int lax, value_ptr *objp, struct symbol *fsym, > value_ptr *valp, struct symbol **symp, int *staticp) > { > int nparms; > struct type **parm_types; > int champ_nparms = 0; > + struct value *obj = (objp ? *objp : NULL); > > short oload_champ = -1; /* Index of best overloaded function */ > short oload_ambiguous = 0; /* Current ambiguity state for overload resolution */ > @@ -2847,6 +2848,15 @@ find_overload_match (struct type **arg_t > xfree (func_name); > } > > + if (objp) > + { > + if (TYPE_CODE (VALUE_TYPE (temp)) != TYPE_CODE_PTR > + && TYPE_CODE (VALUE_TYPE (*objp)) == TYPE_CODE_PTR) > + { > + temp = value_addr (temp); > + } > + *objp = temp; > + } > return oload_incompatible ? 100 : (oload_non_standard ? 10 : 0); > } > > Index: value.h > =================================================================== > RCS file: /cvs/src/src/gdb/value.h,v > retrieving revision 1.22 > diff -u -p -r1.22 value.h > --- value.h 2001/10/16 01:58:07 1.22 > +++ value.h 2001/12/03 15:27:58 > @@ -386,7 +386,7 @@ extern struct fn_field *value_find_oload > > extern int find_overload_match (struct type **arg_types, int nargs, > char *name, int method, int lax, > - value_ptr obj, struct symbol *fsym, > + value_ptr *obj, struct symbol *fsym, > value_ptr * valp, struct symbol **symp, > int *staticp); > >