public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [patch] PR 11992 "Regression: C++ this scope sometimes does not work"
@ 2010-09-10 20:30 sami wagiaalla
  2010-09-10 20:39 ` Tom Tromey
  2010-09-12 18:34 ` Jan Kratochvil
  0 siblings, 2 replies; 4+ messages in thread
From: sami wagiaalla @ 2010-09-10 20:30 UTC (permalink / raw)
  To: gdb-patches

[-- Attachment #1: Type: text/plain, Size: 131 bytes --]

This is a fix and a test case for the above mentioned bug.
The patch was regression testing on F13 on x8664 with gcc 4.4.4.

Sami


[-- Attachment #2: this_regression.patch --]
[-- Type: text/x-patch, Size: 1957 bytes --]

Fix PR 11992: C++ 'this' scope sometimes does not work

2010-09-10  Sami Wagiaalla  <swagiaal@redhat.com>

	PR symtab/11992:
	* c-exp.y (classify_name): Check is_a_member_of_this before returning
	UNKNOWN_CPP_NAME.

2010-09-10  Sami Wagiaalla  <swagiaal@redhat.com>

	* gdb.cp/koenig.cc: created class for testing member lookup.
	* gdb.cp/koenig.exp: Added test for member lookup.

diff --git a/gdb/c-exp.y b/gdb/c-exp.y
index 663e778..57e09b3 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/gdb.cp/koenig.cc b/gdb/testsuite/gdb.cp/koenig.cc
index c91dbf9..d5e7bbe 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 foo(){ return 31; }
+    int bar(){
+      return foo()+1; // marker1
+    }
+};
+
+//------------
+
 int
 main ()
 {
@@ -299,6 +309,9 @@ main ()
 
   ++q;
 
+  R r;
+  r.bar();
+
   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 d5e6c3f..d291a6e 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 effect
+# member variable lookup
+gdb_test "p r.foo()" "= 31"
+
+# Do the same from inside class R
+gdb_breakpoint [gdb_get_line_number "marker1"]
+gdb_continue_to_breakpoint "marker1"
+
+gdb_test "p foo()" "= 31"
+gdb_test "p this->foo()" "= 31"

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [patch] PR 11992 "Regression: C++ this scope sometimes does not work"
  2010-09-10 20:30 [patch] PR 11992 "Regression: C++ this scope sometimes does not work" sami wagiaalla
@ 2010-09-10 20:39 ` Tom Tromey
  2010-09-12 18:34 ` Jan Kratochvil
  1 sibling, 0 replies; 4+ messages in thread
From: Tom Tromey @ 2010-09-10 20:39 UTC (permalink / raw)
  To: sami wagiaalla; +Cc: gdb-patches

>>>>> "Sami" == sami wagiaalla <swagiaal@redhat.com> writes:

Sami> This is a fix and a test case for the above mentioned bug.
Sami> The patch was regression testing on F13 on x8664 with gcc 4.4.4.

Thanks.

Sami> +# test that koening lookup does not effect
Sami> +# member variable lookup

s/effect/affect/

Also, comments should start with an upper case letter and end with a
period.

This is ok with that change.

Tom

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [patch] PR 11992 "Regression: C++ this scope sometimes does not work"
  2010-09-10 20:30 [patch] PR 11992 "Regression: C++ this scope sometimes does not work" sami wagiaalla
  2010-09-10 20:39 ` Tom Tromey
@ 2010-09-12 18:34 ` Jan Kratochvil
  2010-09-13 17:51   ` sami wagiaalla
  1 sibling, 1 reply; 4+ messages in thread
From: Jan Kratochvil @ 2010-09-12 18:34 UTC (permalink / raw)
  To: sami wagiaalla; +Cc: gdb-patches

On Fri, 10 Sep 2010 21:01:56 +0200, sami wagiaalla wrote:
> This is a fix and a test case for the above mentioned bug.
> The patch was regression testing on F13 on x8664 with gcc 4.4.4.

[ I would not call it "gcc 4.4.4", it is gcc-4.4.4-10.fc13 which is far from
FSF GCC 4.4.4. ]

Anyway while it fixes the problem for me on Fedora 13 x86_64 (and even others)
the testcase does not FAIL with FSF GDB HEAD (reproducing the problem from
Dodji as is in the PR).


Thanks,
Jan

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [patch] PR 11992 "Regression: C++ this scope sometimes does not work"
  2010-09-12 18:34 ` Jan Kratochvil
@ 2010-09-13 17:51   ` sami wagiaalla
  0 siblings, 0 replies; 4+ messages in thread
From: sami wagiaalla @ 2010-09-13 17:51 UTC (permalink / raw)
  To: Jan Kratochvil; +Cc: gdb-patches

[-- Attachment #1: Type: text/plain, Size: 461 bytes --]


> [ I would not call it "gcc 4.4.4", it is gcc-4.4.4-10.fc13 which is far from
> FSF GCC 4.4.4. ]
>

Gotcha!

> Anyway while it fixes the problem for me on Fedora 13 x86_64 (and even others)
> the testcase does not FAIL with FSF GDB HEAD (reproducing the problem from
> Dodji as is in the PR).
>

You are right. My bad; I should not have missed that. I fixed the test 
case by giving the new functions their own unique names.

I will commit the attached patch

[-- Attachment #2: this_regression.patch --]
[-- Type: text/x-patch, Size: 1973 bytes --]

Fix PR 11992: C++ 'this' scope sometimes does not work

2010-09-13  Sami Wagiaalla  <swagiaal@redhat.com>

	PR symtab/11992:
	* c-exp.y (classify_name): Check is_a_member_of_this before returning
	UNKNOWN_CPP_NAME.

2010-09-13  Sami Wagiaalla  <swagiaal@redhat.com>

	* gdb.cp/koenig.cc: created class for testing member lookup.
	* gdb.cp/koenig.exp: Added test for member lookup.

diff --git a/gdb/c-exp.y b/gdb/c-exp.y
index 663e778..57e09b3 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/gdb.cp/koenig.cc b/gdb/testsuite/gdb.cp/koenig.cc
index c91dbf9..e2190f1 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 d5e6c3f..34abe77 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"

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2010-09-13 15:04 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-09-10 20:30 [patch] PR 11992 "Regression: C++ this scope sometimes does not work" sami wagiaalla
2010-09-10 20:39 ` Tom Tromey
2010-09-12 18:34 ` Jan Kratochvil
2010-09-13 17:51   ` sami wagiaalla

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).