From 450ca57cacb0f620f94fa16b7ab3ea6e0076383c Mon Sep 17 00:00:00 2001 From: Sami Wagiaalla Date: Mon, 13 Sep 2010 20:41:05 +0000 Subject: [PATCH] Fix PR 11992: C++ 'this' scope sometimes does not work 2010-09-13 Sami Wagiaalla PR symtab/11992: * c-exp.y (classify_name): Check is_a_member_of_this before returning UNKNOWN_CPP_NAME. 2010-09-13 Sami Wagiaalla * gdb.cp/koenig.cc: created class for testing member lookup. * gdb.cp/koenig.exp: Added test for member lookup. --- gdb/ChangeLog | 6 ++++++ gdb/c-exp.y | 1 + gdb/testsuite/ChangeLog | 5 +++++ gdb/testsuite/gdb.cp/koenig.cc | 14 ++++++++++++++ gdb/testsuite/gdb.cp/koenig.exp | 11 +++++++++++ 5 files changed, 37 insertions(+) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 9c3478bad7d..098406044e5 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,9 @@ +2010-09-13 Sami Wagiaalla + + PR symtab/11992: + * c-exp.y (classify_name): Check is_a_member_of_this before returning + UNKNOWN_CPP_NAME. + 2010-09-13 Joel Brobecker * NEWS: Add x86-lynxos to the list of platforms supported by diff --git a/gdb/c-exp.y b/gdb/c-exp.y index 663e778bd41..57e09b33b23 100644 --- a/gdb/c-exp.y +++ b/gdb/c-exp.y @@ -2389,6 +2389,7 @@ classify_name (struct block *block) if (sym == NULL && parse_language->la_language == language_cplus + && !is_a_field_of_this && !lookup_minimal_symbol (copy, NULL, NULL)) return UNKNOWN_CPP_NAME; diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog index a2a4eeef30c..0bcaa7e4147 100644 --- a/gdb/testsuite/ChangeLog +++ b/gdb/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2010-09-13 Sami Wagiaalla + + * gdb.cp/koenig.cc: created class for testing member lookup. + * gdb.cp/koenig.exp: Added test for member lookup. + 2010-09-13 Jan Kratochvil Fix false FAILs on sourcetree topdir directory containing "kill". diff --git a/gdb/testsuite/gdb.cp/koenig.cc b/gdb/testsuite/gdb.cp/koenig.cc index c91dbf95c8a..e2190f1c6c7 100644 --- a/gdb/testsuite/gdb.cp/koenig.cc +++ b/gdb/testsuite/gdb.cp/koenig.cc @@ -226,6 +226,16 @@ namespace P { //------------ +class R { + public: + int rfoo(){ return 31; } + int rbar(){ + return 1; // marker1 + } +}; + +//------------ + int main () { @@ -299,6 +309,10 @@ main () ++q; + R r; + r.rbar(); + r.rfoo(); + return first (0, c) + foo (eo) + foo (eo, eo) + foo (eo, eo, 1) + foo (fo, eo) + foo (1 ,fo, eo) + diff --git a/gdb/testsuite/gdb.cp/koenig.exp b/gdb/testsuite/gdb.cp/koenig.exp index d5e6c3f6132..34abe77ce72 100644 --- a/gdb/testsuite/gdb.cp/koenig.exp +++ b/gdb/testsuite/gdb.cp/koenig.exp @@ -115,3 +115,14 @@ gdb_test "p q + 5" "= 29" # some unary operators for good measure # Cannot resolve function operator++ to any overloaded instance gdb_test "p ++q" "= 30" + +# Test that koening lookup does not affect +# member variable lookup. +gdb_test "p r.rfoo()" "= 31" + +# Do the same from inside class R. +gdb_breakpoint [gdb_get_line_number "marker1"] +gdb_continue_to_breakpoint "marker1" + +gdb_test "p rfoo()" "= 31" +gdb_test "p this->rfoo()" "= 31" -- 2.30.2