From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 24587 invoked by alias); 14 Jan 2002 04:41:21 -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 24550 invoked from network); 14 Jan 2002 04:41:16 -0000 Received: from unknown (HELO localhost.cygnus.com) (24.114.42.213) by sources.redhat.com with SMTP; 14 Jan 2002 04:41:16 -0000 Received: from cygnus.com (localhost [127.0.0.1]) by localhost.cygnus.com (Postfix) with ESMTP id 94C283D20; Sun, 13 Jan 2002 23:41:15 -0500 (EST) Message-ID: <3C42616B.8050401@cygnus.com> Date: Sun, 13 Jan 2002 20:41:00 -0000 From: Andrew Cagney User-Agent: Mozilla/5.0 (X11; U; NetBSD macppc; en-US; rv:0.9.7) Gecko/20020103 X-Accept-Language: en-us MIME-Version: 1.0 To: gdb-patches@sources.redhat.com, Daniel Jacobowitz Subject: [Fwd: [rfa] Call methods with proper promotion] Content-Type: multipart/mixed; boundary="------------000700050807060906050805" X-SW-Source: 2002-01/txt/msg00378.txt.bz2 This is a multi-part message in MIME format. --------------000700050807060906050805 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Content-length: 39 Daniel, did this get resolved? Andrew --------------000700050807060906050805 Content-Type: message/rfc822; name="[rfa] Call methods with proper promotion" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="[rfa] Call methods with proper promotion" Content-length: 5746 X-Mozilla-Status2: 00000000 Return-Path: Delivered-To: ac131313@localhost.cygnus.com Received: from localhost (localhost [127.0.0.1]) by localhost.cygnus.com (Postfix) with ESMTP id 656E03E2A for ; Mon, 3 Dec 2001 23:20:07 -0500 (EST) Received: from pop.cygnus.com by localhost with IMAP (fetchmail-5.8.8) for ac131313@localhost (single-drop); Mon, 03 Dec 2001 23:20:07 -0500 (EST) Received: from sources.redhat.com (sourceware.cygnus.com [209.249.29.67]) by runyon.cygnus.com (8.8.7-cygnus/8.8.7) with SMTP id TAA12615 for ; Mon, 3 Dec 2001 19:52:45 -0800 (PST) Received: (qmail 20936 invoked by alias); 4 Dec 2001 03:52:33 -0000 Received: (qmail 20894 invoked from network); 4 Dec 2001 03:52:27 -0000 Received: from unknown (HELO nevyn.them.org) (128.2.145.6) by sources.redhat.com with SMTP; 4 Dec 2001 03:52:27 -0000 Received: from drow by nevyn.them.org with local (Exim 3.33 #1 (Debian)) id 16B6dh-0004dO-00 for ; Mon, 03 Dec 2001 22:53:01 -0500 Mailing-List: contact gdb-patches-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sources.redhat.com Delivered-To: mailing list gdb-patches@sources.redhat.com Date: Mon, 3 Dec 2001 22:53:01 -0500 From: Daniel Jacobowitz To: gdb-patches@sources.redhat.com Subject: [rfa] Call methods with proper promotion Message-ID: <20011203225301.A14016@nevyn.them.org> Mail-Followup-To: gdb-patches@sources.redhat.com Mime-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.3.23i Content-Type: text/plain; charset=us-ascii Content-length: 3741 [Did this ever work at all? I doubt!] TYPE_NFIELDS () is 0 for methods. The arguments were thus treated by hand_function_call only according to default promotions. Things like call-by-reference never happened. This fixes: -FAIL: gdb.c++/classes.exp: base class (¶m)->a -FAIL: gdb.c++/classes.exp: base class (¶m)->x -FAIL: gdb.c++/classes.exp: inherited class (¶m)->a -FAIL: gdb.c++/classes.exp: inherited class (¶m)->x +PASS: gdb.c++/classes.exp: base class (¶m)->a +PASS: gdb.c++/classes.exp: base class (¶m)->x +PASS: gdb.c++/classes.exp: inherited class (¶m)->a +PASS: gdb.c++/classes.exp: inherited class (¶m)->x No regressions, brings me ever closer on my march towards zero testsuite failures! OK to commit? -- Daniel Jacobowitz Carnegie Mellon University MontaVista Software Debian GNU/Linux Developer 2001-12-03 Daniel Jacobowitz * valops.c (hand_function_call): Check for method arguments in TYPE_ARG_TYPES(), not in TYPE_FIELD (). 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/04 03:45:19 @@ -1320,6 +1320,7 @@ hand_function_call (value_ptr function, CORE_ADDR real_pc; struct type *param_type = NULL; struct type *ftype = check_typedef (SYMBOL_TYPE (function)); + int n_method_args = 0; dummy = alloca (SIZEOF_CALL_DUMMY_WORDS); sizeof_dummy1 = REGISTER_SIZE * SIZEOF_CALL_DUMMY_WORDS / sizeof (ULONGEST); @@ -1424,11 +1425,31 @@ hand_function_call (value_ptr function, sp = old_sp; /* It really is used, for some ifdef's... */ #endif - if (nargs < TYPE_NFIELDS (ftype)) + if (TYPE_CODE (ftype) == TYPE_CODE_METHOD) + { + i = 0; + while (TYPE_CODE (TYPE_ARG_TYPES (ftype)[i]) != TYPE_CODE_VOID) + i++; + n_method_args = i; + if (nargs < i) + error ("too few arguments in method call"); + } + else if (nargs < TYPE_NFIELDS (ftype)) error ("too few arguments in function call"); for (i = nargs - 1; i >= 0; i--) { + /* Assume that methods are always prototyped, unless they are off the + end (which we should only be allowing if there is a ``...''). + FIXME. */ + if (TYPE_CODE (ftype) == TYPE_CODE_METHOD) + { + if (i < n_method_args) + args[i] = value_arg_coerce (args[i], TYPE_ARG_TYPES (ftype)[i], 1); + else + args[i] = value_arg_coerce (args[i], NULL, 0); + } + /* If we're off the end of the known arguments, do the standard promotions. FIXME: if we had a prototype, this should only be allowed if ... were present. */ @@ -2618,12 +2639,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 +2869,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); } --------------000700050807060906050805--