summaryrefslogtreecommitdiff
path: root/gdb/eval.c
diff options
context:
space:
mode:
authorswagiaal <swagiaal>2010-10-19 20:53:13 +0000
committerswagiaal <swagiaal>2010-10-19 20:53:13 +0000
commitdce8ebc2edaca7c4a0dafb0f56fb6d24842bf27f (patch)
tree0f653740f2396ac6294f7f9a5a16ec81ceae23c8 /gdb/eval.c
parentab5fbf66c212fa7e087fd04af41b40bd347f0cf6 (diff)
downloadgdb-dce8ebc2edaca7c4a0dafb0f56fb6d24842bf27f.tar.gz
Support overloading of 'operator->'.
2010-10-19 Sami Wagiaalla <swagiaal@redhat.com> PR C++/11500: * valarith.c (value_x_unop): Handle STRUCTOP_PTR. * eval.c (evaluate_subexp_standard): Check for overload of 'operator->'. * valarith.c (value_x_binop): Throw NOT_FOUND_ERROR. (value_x_unop): Ditto. * valops.c: Include "exceptions.h". (find_overload_match): Throw NOT_FOUND_ERROR. (value_struct_elt): Ditto. 2010-10-19 Sami Wagiaalla <swagiaal@redhat.com> * gdb.cp/smartp.exp: New test. * gdb.cp/smartp.cc : New test.
Diffstat (limited to 'gdb/eval.c')
-rw-r--r--gdb/eval.c43
1 files changed, 43 insertions, 0 deletions
diff --git a/gdb/eval.c b/gdb/eval.c
index 635db34e22a..471dcd7a563 100644
--- a/gdb/eval.c
+++ b/gdb/eval.c
@@ -1510,6 +1510,28 @@ evaluate_subexp_standard (struct type *expect_type,
else
{
arg2 = evaluate_subexp (NULL_TYPE, exp, pos, noside);
+
+ /* Check to see if the operator '->' has been overloaded. If the operator
+ has been overloaded replace arg2 with the value returned by the custom
+ operator and continue evaluation. */
+ while (unop_user_defined_p (op, arg2))
+ {
+ volatile struct gdb_exception except;
+ struct value *value = NULL;
+ TRY_CATCH (except, RETURN_MASK_ERROR)
+ {
+ value = value_x_unop (arg2, op, noside);
+ }
+
+ if (except.reason < 0)
+ {
+ if (except.error == NOT_FOUND_ERROR)
+ break;
+ else
+ throw_exception (except);
+ }
+ arg2 = value;
+ }
}
/* Now, say which argument to start evaluating from */
tem = 2;
@@ -1898,6 +1920,27 @@ evaluate_subexp_standard (struct type *expect_type,
if (noside == EVAL_SKIP)
goto nosideret;
+ /* Check to see if operator '->' has been overloaded. If so replace
+ arg1 with the value returned by evaluating operator->(). */
+ while (unop_user_defined_p (op, arg1))
+ {
+ volatile struct gdb_exception except;
+ struct value *value = NULL;
+ TRY_CATCH (except, RETURN_MASK_ERROR)
+ {
+ value = value_x_unop (arg1, op, noside);
+ }
+
+ if (except.reason < 0)
+ {
+ if (except.error == NOT_FOUND_ERROR)
+ break;
+ else
+ throw_exception (except);
+ }
+ arg1 = value;
+ }
+
/* JYG: if print object is on we need to replace the base type
with rtti type in order to continue on with successful
lookup of member / method only available in the rtti type. */