[gdb/exp] Fix internal error when printing C++ pointer-to-member
authorTom de Vries <tdevries@suse.de>
Tue, 5 Jul 2022 20:41:25 +0000 (22:41 +0200)
committerTom de Vries <tdevries@suse.de>
Tue, 5 Jul 2022 20:41:25 +0000 (22:41 +0200)
commit22f8e2e726629e7f09a49c66a6a2f746a49ba479
tree169ce874f5765641ecc0ea93c2034ff5a6023cb3
parent99298c958c5393402cd2bc2885c195838a9dd363
[gdb/exp] Fix internal error when printing C++ pointer-to-member

When running the test-case included with this patch, we run into:
...
(gdb) print ptm^M
$1 = gdb/gdbtypes.h:695: internal-error: loc_bitpos: \
  Assertion `m_loc_kind == FIELD_LOC_KIND_BITPOS' failed.^M
...
while printing a c++ pointer-to-member.

Fix this by skipping static fields in cp_find_class_member, such that we have:
...
(gdb) print ptm^M
$1 = &A::i^M
...

Tested on x86_64-linux.

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=29294
gdb/cp-valprint.c
gdb/testsuite/gdb.cp/pointer-to-member.cc [new file with mode: 0644]
gdb/testsuite/gdb.cp/pointer-to-member.exp [new file with mode: 0644]