Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Andrew Cagney <ac131313@cygnus.com>
To: gdb-patches@sources.redhat.com, Daniel Jacobowitz <drow@mvista.com>
Subject: [Fwd: [rfa] Call methods with proper promotion]
Date: Sun, 13 Jan 2002 20:41:00 -0000	[thread overview]
Message-ID: <3C42616B.8050401@cygnus.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 39 bytes --]

Daniel, did this get resolved?

Andrew

[-- Attachment #2: [rfa] Call methods with proper promotion --]
[-- Type: message/rfc822, Size: 5767 bytes --]

From: Daniel Jacobowitz <drow@mvista.com>
To: gdb-patches@sources.redhat.com
Subject: [rfa] Call methods with proper promotion
Date: Mon, 3 Dec 2001 22:53:01 -0500
Message-ID: <20011203225301.A14016@nevyn.them.org>

[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 (&param)->a
-FAIL: gdb.c++/classes.exp: base class (&param)->x
-FAIL: gdb.c++/classes.exp: inherited class (&param)->a
-FAIL: gdb.c++/classes.exp: inherited class (&param)->x
+PASS: gdb.c++/classes.exp: base class (&param)->a
+PASS: gdb.c++/classes.exp: base class (&param)->x
+PASS: gdb.c++/classes.exp: inherited class (&param)->a
+PASS: gdb.c++/classes.exp: inherited class (&param)->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  <drow@mvista.com>

	* 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);
 }
 


             reply	other threads:[~2002-01-14  4:41 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-01-13 20:41 Andrew Cagney [this message]
2002-01-13 20:54 ` Daniel Jacobowitz

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3C42616B.8050401@cygnus.com \
    --to=ac131313@cygnus.com \
    --cc=drow@mvista.com \
    --cc=gdb-patches@sources.redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox