aboutsummaryrefslogtreecommitdiff
path: root/gdb/valops.c
diff options
context:
space:
mode:
authorKeith Seitz <keiths@redhat.com>2013-11-25 13:37:08 -0800
committerKeith Seitz <keiths@redhat.com>2013-11-25 13:37:08 -0800
commitf7e3ecae9ff55b69aab93af61a7f7ca272d03d0a (patch)
tree8b09679efbdab89ae85dbbb6a03d9890ff0433c2 /gdb/valops.c
parentb02677b9040a23788b4e07c7cfbf75eca0aa2775 (diff)
downloadgdb-f7e3ecae9ff55b69aab93af61a7f7ca272d03d0a.zip
gdb-f7e3ecae9ff55b69aab93af61a7f7ca272d03d0a.tar.gz
gdb-f7e3ecae9ff55b69aab93af61a7f7ca272d03d0a.tar.bz2
PR c++/14819: Explicit class:: inside class scope does not work
https://sourceware.org/ml/gdb-patches/2013-11/msg00102.html
Diffstat (limited to 'gdb/valops.c')
-rw-r--r--gdb/valops.c29
1 files changed, 27 insertions, 2 deletions
diff --git a/gdb/valops.c b/gdb/valops.c
index 4fc57ec..8e7b16f 100644
--- a/gdb/valops.c
+++ b/gdb/valops.c
@@ -3128,10 +3128,35 @@ value_struct_elt_for_reference (struct type *domain, int offset,
return value_from_longest
(lookup_memberptr_type (TYPE_FIELD_TYPE (t, i), domain),
offset + (LONGEST) (TYPE_FIELD_BITPOS (t, i) >> 3));
- else if (noside == EVAL_AVOID_SIDE_EFFECTS)
+ else if (noside != EVAL_NORMAL)
return allocate_value (TYPE_FIELD_TYPE (t, i));
else
- error (_("Cannot reference non-static field \"%s\""), name);
+ {
+ /* Try to evaluate NAME as a qualified name with implicit
+ this pointer. In this case, attempt to return the
+ equivalent to `this->*(&TYPE::NAME)'. */
+ v = value_of_this_silent (current_language);
+ if (v != NULL)
+ {
+ struct value *ptr;
+ long mem_offset;
+ struct type *type, *tmp;
+
+ ptr = value_aggregate_elt (domain, name, NULL, 1, noside);
+ type = check_typedef (value_type (ptr));
+ gdb_assert (type != NULL
+ && TYPE_CODE (type) == TYPE_CODE_MEMBERPTR);
+ tmp = lookup_pointer_type (TYPE_DOMAIN_TYPE (type));
+ v = value_cast_pointers (tmp, v, 1);
+ mem_offset = value_as_long (ptr);
+ tmp = lookup_pointer_type (TYPE_TARGET_TYPE (type));
+ result = value_from_pointer (tmp,
+ value_as_long (v) + mem_offset);
+ return value_ind (result);
+ }
+
+ error (_("Cannot reference non-static field \"%s\""), name);
+ }
}
}