From 7d3fe98e4f161e15cbb329cc44da260abadfb2fd Mon Sep 17 00:00:00 2001 From: Sami Wagiaalla Date: Wed, 2 Jun 2010 15:31:30 +0000 Subject: [PATCH] Fix ADL anonymous name crash. 2010-06-02 Sami Wagiaalla * cp-support.c (make_symbol_overload_list_adl_namespace): Handle anonymous type case. 2010-06-02 Sami Wagiaalla * gdb.cp/koenig.exp: Added new test case. * gdb.cp/koenig.cc: Ditto. --- gdb/ChangeLog | 5 +++++ gdb/cp-support.c | 3 +++ gdb/testsuite/ChangeLog | 5 +++++ gdb/testsuite/gdb.cp/koenig.cc | 7 +++++++ gdb/testsuite/gdb.cp/koenig.exp | 5 +++++ 5 files changed, 25 insertions(+) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 16b5801509..7cd0030157 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,8 @@ +2010-06-02 Sami Wagiaalla + + * cp-support.c (make_symbol_overload_list_adl_namespace): Handle + anonymous type case. + 2010-06-02 Pierre Muller * dwarf2read.c (read_subrange_type): Handle missing base type diff --git a/gdb/cp-support.c b/gdb/cp-support.c index e4b5d4d7b5..799b7076da 100644 --- a/gdb/cp-support.c +++ b/gdb/cp-support.c @@ -752,6 +752,9 @@ make_symbol_overload_list_adl_namespace (struct type *type, type_name = TYPE_NAME (type); + if (type_name == NULL) + return; + prefix_len = cp_entire_prefix_len (type_name); if (prefix_len != 0) diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog index 01f824235c..3cae6ff5a4 100644 --- a/gdb/testsuite/ChangeLog +++ b/gdb/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2010-06-02 Sami Wagiaalla + + * gdb.cp/koenig.exp: Added new test case. + * gdb.cp/koenig.cc: Ditto. + 2010-06-01 Michael Snyder * gdb.base/arithmet.exp: Use gdb_test_no_output. diff --git a/gdb/testsuite/gdb.cp/koenig.cc b/gdb/testsuite/gdb.cp/koenig.cc index 6cfa3f588c..fb4ecb14ee 100644 --- a/gdb/testsuite/gdb.cp/koenig.cc +++ b/gdb/testsuite/gdb.cp/koenig.cc @@ -175,6 +175,13 @@ typedef O::A TOA; typedef TOA TTOA; //------------ +static union { + int a; + char b; +}p_union; + +//------------ + int main () { diff --git a/gdb/testsuite/gdb.cp/koenig.exp b/gdb/testsuite/gdb.cp/koenig.exp index 8de3d11114..57be74500a 100644 --- a/gdb/testsuite/gdb.cp/koenig.exp +++ b/gdb/testsuite/gdb.cp/koenig.exp @@ -64,6 +64,7 @@ gdb_test "p foo(go, fo, eo)" "= 6" #test that gdb fails gracefully gdb_test "p fake(eo)" "No symbol \"fake\" in current context." +gdb_test "p foo (fake)" "No symbol \"fake\" in current context." #test that namespaces of base classes are searched gdb_test "p foo(io)" "= 7" @@ -104,3 +105,7 @@ gdb_test "p M::N::bar('a')" "= 22" #test that lookup supports typedef gdb_test "p foo(ttoa, 'a')" "= 23" + +#test that lookup is not thwarted by anonymous types +gdb_test "p foo (p_union)" \ + "Cannot resolve function foo to any overloaded instance"