Bug 7943 - GDB doesn't do Koenig lookup
Summary: GDB doesn't do Koenig lookup
Status: RESOLVED FIXED
Alias: None
Product: gdb
Classification: Unclassified
Component: c++ (show other bugs)
Version: unknown
: P3 normal
Target Milestone: 7.2
Assignee: Sami Wagiaalla
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2002-11-19 14:28 UTC by David Carlton
Modified: 2010-07-20 19:45 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description David Carlton 2002-11-19 22:28:00 UTC
[Converted from Gnats 838]

GDB doesn't know about Koenig lookup in C++.  (Koenig lookup
tells the compiler to search in extra namespaces when trying
to find a function, based on the namespaces that the types
of its args live in.)

Release:
GNU gdb 2002-11-15-cvs

Environment:
any

How-To-Repeat:
Compile the following file:

namespace A {
  class C {
  };

  void foo(C arg)
  {
  }
}

int main()
{
  A::C theC;

  foo(theC);
}

Run GDB on it, and try to print out foo(theC) (as
opposed to, say, 'A::foo'(theC).

(gdb) b main
Breakpoint 1 at 0x80484a6: file koenig.cc, line 14.
(gdb) r
Starting program: /cartan/carlton/sync/gdb-backup/namespace/prs/koenig 

Breakpoint 1, main () at koenig.cc:14
14	  foo(theC);
(gdb) p foo(theC)
No symbol "foo" in current context.
(gdb) p 'A::foo'(theC)
$1 = void
Comment 1 David Carlton 2002-11-19 22:28:00 UTC
Fix:
This will take a little while...
Comment 2 Sourceware Commits 2010-05-07 14:47:07 UTC
Subject: Bug 7943

CVSROOT:	/cvs/src
Module name:	src
Changes by:	swagiaal@sourceware.org	2010-05-07 14:46:29

Modified files:
	gdb            : ChangeLog c-exp.y cp-support.c cp-support.h 
	                 eval.c expprint.c expression.h parse.c valops.c 
	                 value.h 
	gdb/testsuite  : ChangeLog 
Added files:
	gdb/testsuite/gdb.cp: koenig.cc koenig.exp 

Log message:
	Add ADL support
	
	2010-05-07  Sami Wagiaalla  <swagiaal@redhat.com>
	
	PR C++/7943:
	* valops.c (find_overload_match): Handle fsym == NULL case.
	Add int no_adl argument.
	(find_oload_champ_namespace_loop): Call make_symbol_overload_list_adl
	when appropriate.
	Add int no_adl argument.
	(find_oload_champ_namespace): 	Add int no_adl argument.
	* parse.c (operator_length_standard): Return length for OP_ADL_FUNC
	expression.
	* expprint.c (op_name_standard): Added string for OP_ADL_FUNC case.
	* eval.c (evaluate_subexp_standard): Added OP_ADL_FUNC case.
	Evaluate arguments and use them to perform ADL lookup.
	Pass no_adl argument to find_overload_match.
	Disable adl lookup when evaluating a fully qualified OP_FUNCALL.
	* cp-support.h: Added prototype for
	make_symbol_overload_list_namespace.
	* cp-support.c (make_symbol_overload_list_namespace): New function.
	(make_symbol_overload_list_adl_namespace): New function.
	(make_symbol_overload_list_adl): New function.
	(make_symbol_overload_list_using): Moved code to add function to
	overload set to make_symbol_overload_list_namespace.
	* c-exp.y: create UNKNOWN_CPP_NAME token.
	Add parse rule for ADL functions.
	(classify_name): Recognize an UNKNOWN_CPP_NAME.
	
	2010-05-07  Sami Wagiaalla  <swagiaal@redhat.com>
	
	* gdb.cp/koenig.exp: New test.
	* gdb.cp/koenig.cc: New test program.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/ChangeLog.diff?cvsroot=src&r1=1.11762&r2=1.11763
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/c-exp.y.diff?cvsroot=src&r1=1.74&r2=1.75
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/cp-support.c.diff?cvsroot=src&r1=1.38&r2=1.39
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/cp-support.h.diff?cvsroot=src&r1=1.37&r2=1.38
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/eval.c.diff?cvsroot=src&r1=1.130&r2=1.131
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/expprint.c.diff?cvsroot=src&r1=1.42&r2=1.43
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/expression.h.diff?cvsroot=src&r1=1.34&r2=1.35
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/parse.c.diff?cvsroot=src&r1=1.97&r2=1.98
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/valops.c.diff?cvsroot=src&r1=1.240&r2=1.241
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/value.h.diff?cvsroot=src&r1=1.155&r2=1.156
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/testsuite/ChangeLog.diff?cvsroot=src&r1=1.2262&r2=1.2263
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/testsuite/gdb.cp/koenig.cc.diff?cvsroot=src&r1=NONE&r2=1.1
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/testsuite/gdb.cp/koenig.exp.diff?cvsroot=src&r1=NONE&r2=1.1

Comment 3 Tom Tromey 2010-07-20 19:45:00 UTC
Fixed in 7.2.