Modified Files:
authorKung Hsu <kung@cygnus>
Wed, 17 Nov 1993 18:07:58 +0000 (18:07 +0000)
committerKung Hsu <kung@cygnus>
Wed, 17 Nov 1993 18:07:58 +0000 (18:07 +0000)
ChangeLog eval.c valops.c

        * valops.c (typecmp): improve prototype matching when calling
        a method. Make 'p (*(ostream *) &cout) << "lll" ' to work.
        * eval.c(evalute_subexp): fix operator search problem when call
        like  p x.'operator+'(i).

gdb/ChangeLog
gdb/eval.c
gdb/valops.c

index 96c9179ca35981e16fba8a96ebfa7cb5aa36fbd8..27123568dd531d9669ab9e5268ca76c48e94d0a0 100644 (file)
@@ -1,3 +1,10 @@
+Wed Nov 17 09:43:31 1993  Kung Hsu  (kung@cirdan.cygnus.com)
+
+       * valops.c (typecmp): improve prototype matching when calling
+       a method. Make 'p (*(ostream *) &cout) << "lll" ' to work.
+       * eval.c(evalute_subexp): fix operator search problem when call
+       like  p x.'operator+'(i).
+
 Tue Nov 16 17:15:03 1993  Stu Grossman  (grossman at cygnus.com)
 
        * i386ly-nat.c, i386lynx-nat.c, m68kly-nat.c:  Remove.  Move
index 4aba99f777b2abf207bed5ef3ca463f9532bad97..a5a831569b28b19d70996f452a32a0cc4a13b79b 100644 (file)
@@ -24,6 +24,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
 #include "expression.h"
 #include "target.h"
 #include "frame.h"
+#include "demangle.h"
 #include "language.h"  /* For CAST_IS_CONVERSION */
 
 /* Values of NOSIDE argument to eval_subexp.  */
@@ -163,8 +164,8 @@ evaluate_subexp (expect_type, exp, pos, noside)
 {
   enum exp_opcode op;
   int tem, tem2, tem3;
-  register int pc, pc2, oldpos;
-  register value arg1, arg2, arg3;
+  register int pc, pc2 = 0, oldpos;
+  register value arg1 = NULL, arg2 = NULL, arg3;
   struct type *type;
   int nargs;
   value *argvec;
@@ -202,7 +203,7 @@ evaluate_subexp (expect_type, exp, pos, noside)
        goto nosideret;
       if (noside == EVAL_AVOID_SIDE_EFFECTS)
        {
-         struct symbol * sym = exp->elts[pc + 1].symbol;
+         struct symbol * sym = exp->elts[pc + 2].symbol;
          enum lval_type lv;
 
          switch (SYMBOL_CLASS (sym))
@@ -416,19 +417,50 @@ evaluate_subexp (expect_type, exp, pos, noside)
        {
          int static_memfuncp;
          value temp = arg2;
+         char tstr[15], mangle_tstr[15], *ptr, *mangle_ptr;
+         char *pp;
 
          argvec[1] = arg2;
-         argvec[0] =
-           value_struct_elt (&temp, argvec+1, &exp->elts[pc2 + 2].string,
+         argvec[0] = 0;
+         strcpy(tstr, &exp->elts[pc2+2].string);
+         if (!strncmp(tstr, "operator", 8))
+           {
+              ptr = &tstr[8];
+              strcpy(mangle_tstr, "__");
+              mangle_ptr = &mangle_tstr[2];
+              pp = cplus_mangle_opname(ptr, DMGL_ANSI);
+              if (pp) 
+                strcpy(mangle_ptr, pp);
+              else
+                strcpy(mangle_ptr, ptr);
+              argvec[0] =
+                value_struct_elt (&temp, argvec+1, mangle_tstr,
                              &static_memfuncp,
                              op == STRUCTOP_STRUCT
                              ? "structure" : "structure pointer");
-         if (VALUE_OFFSET (temp))
+              if (!argvec[0]) 
+                {
+                   pp = cplus_mangle_opname(ptr, DMGL_NO_OPTS);
+                   if (pp) 
+                     strcpy(mangle_ptr, pp);
+                   else
+                     strcpy(mangle_ptr, ptr);
+                   strcpy(tstr, mangle_tstr);
+                }
+           }
+          if (!argvec[0]) 
            {
-             arg2 = value_from_longest (lookup_pointer_type (VALUE_TYPE (temp)),
-                                        VALUE_ADDRESS (temp)+VALUE_OFFSET (temp));
-             argvec[1] = arg2;
+             temp = arg2;
+             argvec[0] =
+             value_struct_elt (&temp, argvec+1, tstr,
+                             &static_memfuncp,
+                             op == STRUCTOP_STRUCT
+                             ? "structure" : "structure pointer");
            }
+         arg2 = value_from_longest (lookup_pointer_type(VALUE_TYPE (temp)),
+                        VALUE_ADDRESS (temp)+VALUE_OFFSET (temp));
+         argvec[1] = arg2;
+
          if (static_memfuncp)
            {
              argvec[1] = argvec[0];
index ebddb5b90b4d5f1dad4b2c17da86730652c7f879..52f3bc450e96dad9d7442a423b7e4c4f301ba6e9 100644 (file)
@@ -1278,21 +1278,27 @@ typecmp (staticp, t1, t2)
   if (t1[!staticp] == 0) return 0;
   for (i = !staticp; t1[i] && TYPE_CODE (t1[i]) != TYPE_CODE_VOID; i++)
     {
+    struct type *tt1, *tt2;
       if (! t2[i])
        return i+1;
-      if (TYPE_CODE (t1[i]) == TYPE_CODE_REF
+      tt1 = t1[i];
+      tt2 = VALUE_TYPE(t2[i]);
+      if (TYPE_CODE (tt1) == TYPE_CODE_REF
          /* We should be doing hairy argument matching, as below.  */
-         && (TYPE_CODE (TYPE_TARGET_TYPE (t1[i]))
-             == TYPE_CODE (VALUE_TYPE (t2[i]))))
+         && (TYPE_CODE (TYPE_TARGET_TYPE (tt1)) == TYPE_CODE (tt2)))
        {
          t2[i] = value_addr (t2[i]);
          continue;
        }
 
-      if (TYPE_CODE (t1[i]) == TYPE_CODE_PTR
-         && TYPE_CODE (VALUE_TYPE (t2[i])) == TYPE_CODE_ARRAY)
-       /* Array to pointer is a `trivial conversion' according to the ARM.  */
-       continue;
+      while (TYPE_CODE (tt1) == TYPE_CODE_PTR
+         && (TYPE_CODE(tt2)==TYPE_CODE_ARRAY || TYPE_CODE(tt2)==TYPE_CODE_PTR))
+       {
+          tt1 = TYPE_TARGET_TYPE(tt1); 
+          tt2 = TYPE_TARGET_TYPE(tt2);
+       }
+      if (TYPE_CODE(tt1) == TYPE_CODE(tt2)) continue;
+      /* Array to pointer is a `trivial conversion' according to the ARM.  */
 
       /* We should be doing much hairier argument matching (see section 13.2
         of the ARM), but as a quick kludge, just check for the same type
@@ -1400,6 +1406,7 @@ search_struct_method (name, arg1p, args, offset, static_memfuncp, type)
      register struct type *type;
 {
   int i;
+  value v;
   static int name_matched = 0;
 
   check_stub_type (type);
@@ -1425,7 +1432,8 @@ search_struct_method (name, arg1p, args, offset, static_memfuncp, type)
                    return (value)value_virtual_fn_field (arg1p, f, j, type, offset);
                  if (TYPE_FN_FIELD_STATIC_P (f, j) && static_memfuncp)
                    *static_memfuncp = 1;
-                 return (value)value_fn_field (arg1p, f, j, type, offset);
+                 v = (value)value_fn_field (arg1p, f, j, type, offset);
+                 if (v != (value)NULL) return v;
                }
              j--;
            }
@@ -1434,7 +1442,6 @@ search_struct_method (name, arg1p, args, offset, static_memfuncp, type)
 
   for (i = TYPE_N_BASECLASSES (type) - 1; i >= 0; i--)
     {
-      value v;
       int base_offset;
 
       if (BASETYPE_VIA_VIRTUAL (type, i))
@@ -1547,9 +1554,10 @@ value_struct_elt (argp, args, name, static_memfuncp, err)
       if (!args[1])
        {
          /* destructors are a special case.  */
-         return (value)value_fn_field (NULL, TYPE_FN_FIELDLIST1 (t, 0),
-                                       TYPE_FN_FIELDLIST_LENGTH (t, 0),
-                                       0, 0);
+         v = (value)value_fn_field (NULL, TYPE_FN_FIELDLIST1 (t, 0),
+                               TYPE_FN_FIELDLIST_LENGTH (t, 0), 0, 0);
+         if (!v) error("could not find destructor function named %s.", name);
+         else return v;
        }
       else
        {