Bug 11543 - using-directive does not autocomplete
Summary: using-directive does not autocomplete
Status: ASSIGNED
Alias: None
Product: gdb
Classification: Unclassified
Component: c++ (show other bugs)
Version: unknown
: P2 minor
Target Milestone: 7.1
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on: 11832
Blocks:
  Show dependency treegraph
 
Reported: 2010-04-26 21:18 UTC by Jan Kratochvil
Modified: 2010-07-22 15:38 UTC (History)
2 users (show)

See Also:
Host:
Target: x86_64-unknown-linux-gnu
Build:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jan Kratochvil 2010-04-26 21:18:22 UTC
namespace A { int variablex = 1; }
int main (void)
{
  int variabley = 2;
  using namespace A;
  return 0; /* break-here */
}
-------------------------------------------------------------------------------
(gdb) p variablex
$1 = 1
(gdb) p variabley
$2 = 2
But when I type
(gdb) p vari<tab>
it autocompletes to:
(gdb) p variabley
without any trace of "variablex" being also available.

I am not completely sure it is the right behavior but I believe so.
Comment 1 Chris Moller 2010-04-27 16:47:09 UTC
The problem is that in symtab.c:completion_list_add_name(), qualified names show
up as "A::variablex" and the first test is a trivial reject of strcmp(..., ...)
that matches the beginning of the symname with the beginning of the target,
thereby comparing the target to the qualifier and failing.

Trivial to fix by skipping past the qualifier in the symname.

Two questions:

  1.  Should skipping the qualifier be the default behaviour?  Or should doing
that be some kind of option?

  2.  Are multiple qualifiers like "A::B::variablex" possible?
Comment 2 Sami Wagiaalla 2010-04-28 15:30:35 UTC
The question is whether symtab.c:completion_list_add_name
looks at current import statements (using namespace A).
To add support for something like that would require duplicating a lot of the
code that currently does namespace lookup in completion_list_add_name.

IMO the right thing to do is to modify the lookup_* functions to optionally
return a list of all matching names so that the code can be reused. The same
thing applies to the lookup procedure performed during overload resolution.
Seems like a lot of work but it is the right thing to do.