)]}'
{
  "commit": "6f6e739987d6f0b904aa8e6d6bc7cc4e3d71d408",
  "tree": "eba7772716d1a6ed721aef12011ceca53ba14df0",
  "parents": [
    "3288b2db63ce1a747fbe6dd948379be1be8b86e6"
  ],
  "author": {
    "name": "Tom de Vries",
    "email": "tdevries@suse.de",
    "time": "Tue Jul 14 10:43:14 2026 +0200"
  },
  "committer": {
    "name": "Tom de Vries",
    "email": "tdevries@suse.de",
    "time": "Tue Jul 14 10:43:14 2026 +0200"
  },
  "message": "[gdb/exp] Fix ignoring of incorrect namespace prefix\n\nConsider test.c, compiled to a.out using \"g++ -g test.c\":\n...\n     1  namespace mod_a { int xxx \u003d 10; }\n     2  namespace mod_b { using namespace mod_a;\n     3                    int yyy \u003d 20; }\n     4  int main (void) {\n     5    using namespace mod_b;\n     6    void (xxx + yyy);\n     7    return 0;\n     8  }\n...\n\nWhen trying to print the value of non-existent variable mod_a::yyy, we get:\n...\n$ gdb -q -batch a.out -ex start -ex \"print mod_a::yyy\"\n  ...\nTemporary breakpoint 1, main () at test.c:7\n7         return 0;\n$1 \u003d 20\n...\n\nThe problem is in cp_lookup_symbol_via_imports, where we decide that the\n\"using namespace mod_b\" from main is applicable in scope mod_a.\n\nMore concretely, cp_lookup_symbol_via_imports is called with:\n- scope \u003d\u003d \"mod_a\",\n- name \u003d\u003d \"yyy\", and\n- block.m_function.m_name \u003d\u003d \"main()\",\nand when looking at \"using namespace mod_b\":\n...\n(gdb) p *current\n$12 \u003d {import_src \u003d 0x344018c \"mod_b\", import_dest \u003d 0x1b477a0 \"\",\n       alias \u003d 0x0, declaration \u003d 0x0, next \u003d 0x0, decl_line \u003d 5,\n       searched \u003d 0, excludes \u003d {0x0}}\n...\nwe hit \"directive_match \u003d true\" because strlen (current-\u003eimport_dest) \u003d\u003d 0.\n\nFix this by being more strict in the calculation of directive_match:\n...\n          if (len \u003d\u003d 0)\n-           directive_match \u003d true;\n+           {\n+             const char *current_scope \u003d (block-\u003efunction_block () !\u003d nullptr\n+                                          ? block-\u003escope ()\n+                                          : nullptr /* Don\u0027t know.  */);\n+             directive_match \u003d (current_scope !\u003d nullptr\n+                                ? streq (scope, current_scope)\n+                                : true /* Assume there\u0027s a match.  */);\n+           }\n...\nwhich gets us:\n- current_scope \u003d\u003d \"\", and\n- directive_match \u003d\u003d false,\nbecause scope \u003d\u003d \"mod_a\", so streq (scope, current_scope) \u003d\u003d false.\n\nAs is clear from the code, in case we don\u0027t know the current scope, we assume\nthere\u0027s a match.  This may be harmless, or this may describe a cornercase we\nhaven\u0027t run into yet.  If so, it\u0027s a pre-existing issue.\n\nThe new test-case contains regression tests for:\n- PR34051, and\n- PR34034 for which it contains a kfail.\n\nBug: https://sourceware.org/bugzilla/show_bug.cgi?id\u003d34051\n",
  "tree_diff": [
    {
      "type": "modify",
      "old_id": "87c491d821b63a3e2bde0cffd7f93b72878cbdda",
      "old_mode": 33188,
      "old_path": "gdb/cp-namespace.c",
      "new_id": "17c4d40e294b85037c8a04abd4b14cd21aecbbcc",
      "new_mode": 33188,
      "new_path": "gdb/cp-namespace.c"
    },
    {
      "type": "add",
      "old_id": "0000000000000000000000000000000000000000",
      "old_mode": 0,
      "old_path": "/dev/null",
      "new_id": "226bda3e1014de8a5aa386e20f6a5b48636b93a4",
      "new_mode": 33188,
      "new_path": "gdb/testsuite/gdb.cp/nsusing-2.cc"
    },
    {
      "type": "add",
      "old_id": "0000000000000000000000000000000000000000",
      "old_mode": 0,
      "old_path": "/dev/null",
      "new_id": "65e685d0d3222f9afba7477613ed7769110308d7",
      "new_mode": 33188,
      "new_path": "gdb/testsuite/gdb.cp/nsusing-2.exp"
    }
  ]
}
