* eval.c (evaluate_subexp_standard): Fix setup of ``this'' pointer
authorPeter Schauer <Peter.Schauer@mytum.de>
Sat, 16 Mar 2002 20:51:44 +0000 (20:51 +0000)
committerPeter Schauer <Peter.Schauer@mytum.de>
Sat, 16 Mar 2002 20:51:44 +0000 (20:51 +0000)
for method resolution.  Restore adjustment of ``this'' pointer after
calling value_struct_elt, which was accidentally removed during the
HP merge.

gdb/ChangeLog
gdb/eval.c

index 56e0434..d6e49f8 100644 (file)
@@ -1,3 +1,10 @@
+2002-03-16  Peter Schauer  <pes@regent.e-technik.tu-muenchen.de>
+
+       * eval.c (evaluate_subexp_standard): Fix setup of ``this'' pointer
+       for method resolution.  Restore adjustment of ``this'' pointer after
+       calling value_struct_elt, which was accidentally removed during the
+       HP merge.
+
 2002-03-15  Andrew Cagney  <ac131313@redhat.com>
 
        * eval.c (evaluate_subexp_standard): Pass ``selected_frame'' to
index 0b42a58..4b2d9b8 100644 (file)
@@ -1,6 +1,6 @@
 /* Evaluate expressions for GDB.
    Copyright 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995,
-   1996, 1997, 1998, 1999, 2000, 2001
+   1996, 1997, 1998, 1999, 2000, 2001, 2002
    Free Software Foundation, Inc.
 
    This file is part of GDB.
@@ -820,15 +820,10 @@ evaluate_subexp_standard (struct type *expect_type,
       if (op == STRUCTOP_STRUCT || op == STRUCTOP_PTR)
        {
          int static_memfuncp;
-         struct value *temp = arg2;
          char tstr[256];
 
          /* Method invocation : stuff "this" as first parameter */
-         /* pai: this used to have lookup_pointer_type for some reason,
-          * but temp is already a pointer to the object */
-         argvec[1]
-           = value_from_pointer (VALUE_TYPE (temp),
-                                 VALUE_ADDRESS (temp) + VALUE_OFFSET (temp));
+         argvec[1] = arg2;
          /* Name of method from expression */
          strcpy (tstr, &exp->elts[pc2 + 2].string);
 
@@ -854,11 +849,17 @@ evaluate_subexp_standard (struct type *expect_type,
          else
            /* Non-C++ case -- or no overload resolution */
            {
-             temp = arg2;
+             struct value *temp = arg2;
              argvec[0] = value_struct_elt (&temp, argvec + 1, tstr,
                                            &static_memfuncp,
                                            op == STRUCTOP_STRUCT
                                       ? "structure" : "structure pointer");
+             /* value_struct_elt updates temp with the correct value
+                of the ``this'' pointer if necessary, so modify argvec[1] to
+                reflect any ``this'' changes.  */
+             arg2 = value_from_longest (lookup_pointer_type(VALUE_TYPE (temp)),
+                            VALUE_ADDRESS (temp) + VALUE_OFFSET (temp)
+                            + VALUE_EMBEDDED_OFFSET (temp));
              argvec[1] = arg2; /* the ``this'' pointer */
            }