[PATCH v3 0/2] [gdb/exp] Fix ignoring of incorrect namespace prefix

Tom de Vries
2026-04-10T12:12:28Z

Hafiz Abid Qadeer reported a problem with namespace handling using a Fortran
program [1]. I wrote an equivalent program in C++, and reproduced the
reported problem with both. While investigating the problem, I ran into
another problem, for which I filed PR34051.

This series contains two patches.

The first patch refactors a complex assignment in
cp_lookup_symbol_via_imports.

The second patch fixes PR34051, in that same assignment.

Tested on aarch64-linux.

A v1 was submitted here [2].

New in v2 [3]:
- updated type of directive_match to bool

New in v3:
- fixed top-level "return -1" in test-case
- fixed typo in test-case

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=34051

[1] https://sourceware.org/bugzilla/show_bug.cgi?id=34034
[2] v1 https://sourceware.org/pipermail/gdb-patches/2026-April/226370.html
[3] v2 https://sourceware.org/pipermail/gdb-patches/2026-April/226375.html

Tom de Vries (2):
[gdb] Break up complex assignment in cp_lookup_symbol_via_imports
[gdb/exp] Fix ignoring of incorrect namespace prefix

gdb/cp-namespace.c | 28 ++++++++---
gdb/testsuite/gdb.cp/nsusing-2.cc | 39 ++++++++++++++++
gdb/testsuite/gdb.cp/nsusing-2.exp | 75 ++++++++++++++++++++++++++++++
3 files changed, 135 insertions(+), 7 deletions(-)
create mode 100644 gdb/testsuite/gdb.cp/nsusing-2.cc
create mode 100644 gdb/testsuite/gdb.cp/nsusing-2.exp

base-commit: 65e4798d49afe18c20acd5f5830e706b175ba844
--
2.51.0