* configure.ac (DEBUGDIR_RELOCATABLE): Define for debugdir inside
[deliverable/binutils-gdb.git] / gdb / infcall.c
index c8a63348ee3743d90011b68bffcdbc00a9a52902..c4435e5822949c4091a9054bcfa040a27de11443 100644 (file)
@@ -1,7 +1,7 @@
 /* Perform an inferior function call, for GDB, the GNU debugger.
 
-   Copyright (C) 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994,
-   1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005
+   Copyright (C) 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995,
+   1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007
    Free Software Foundation, Inc.
 
    This file is part of GDB.
@@ -109,14 +109,20 @@ value_arg_coerce (struct value *arg, struct type *param_type,
   switch (TYPE_CODE (type))
     {
     case TYPE_CODE_REF:
-      if (TYPE_CODE (arg_type) != TYPE_CODE_REF
-         && TYPE_CODE (arg_type) != TYPE_CODE_PTR)
-       {
-         arg = value_addr (arg);
-         deprecated_set_value_type (arg, param_type);
-         return arg;
-       }
-      break;
+      {
+       struct value *new_value;
+
+       if (TYPE_CODE (arg_type) == TYPE_CODE_REF)
+         return value_cast_pointers (type, arg);
+
+       /* Cast the value to the reference's target type, and then
+          convert it back to a reference.  This will issue an error
+          if the value was not previously in memory - in some cases
+          we should clearly be allowing this, but how?  */
+       new_value = value_cast (TYPE_TARGET_TYPE (type), arg);
+       new_value = value_ref (new_value);
+       return new_value;
+      }
     case TYPE_CODE_INT:
     case TYPE_CODE_CHAR:
     case TYPE_CODE_BOOL:
@@ -163,7 +169,8 @@ value_arg_coerce (struct value *arg, struct type *param_type,
     case TYPE_CODE_STRING:
     case TYPE_CODE_BITSTRING:
     case TYPE_CODE_ERROR:
-    case TYPE_CODE_MEMBER:
+    case TYPE_CODE_MEMBERPTR:
+    case TYPE_CODE_METHODPTR:
     case TYPE_CODE_METHOD:
     case TYPE_CODE_COMPLEX:
     default:
@@ -330,6 +337,9 @@ call_function_by_hand (struct value *function, int nargs, struct value **args)
   struct cleanup *caller_regcache_cleanup;
   struct frame_id dummy_id;
 
+  if (TYPE_CODE (ftype) == TYPE_CODE_PTR)
+    ftype = check_typedef (TYPE_TARGET_TYPE (ftype));
+
   if (!target_has_execution)
     noprocess ();
 
This page took 0.023705 seconds and 4 git commands to generate.