public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [patch] Fix C++ leading :: (PR c++/11703 and PR gdb/1448)
@ 2010-06-26  8:22 Jan Kratochvil
  2010-06-28 18:28 ` Tom Tromey
  0 siblings, 1 reply; 3+ messages in thread
From: Jan Kratochvil @ 2010-06-26  8:22 UTC (permalink / raw)
  To: gdb-patches; +Cc: Sami Wagiaalla

Hi,

while I do not know much about the C++ parser it seems to me the conditional
there was intended to contain even FIRST_ITER.  Currently it just drops the
whole namespace for ::namespace::object references.

If we remove this whole short-cutting block:
      if (first_was_coloncolon)
        {
          yylval = cc.value;
          return COLONCOLON;
        }
it will crash later on
  yylval.sval.ptr = obstack_copy0 (&expansion_obstack,
                                   yylval.sval.ptr,
                                   yylval.sval.length);
due to uninitialized yylval.sval.ptr and yylval.sval.length.

Maybe a more clear/straightforward conditional could be chosen than
`first_was_coloncolon && first_iter' to just really check yylval.sval.ptr has
been initialized.  But from some higher level point of view the equivalent
conditional `first_was_coloncolon && first_iter' makes sense there.

This patch (its testcase) is dependent on:
	Re: [patch 1/2] Search typedefs in namespaces also in other files
	http://sourceware.org/ml/gdb-patches/2010-06/msg00609.html

No regressions on {x86_64,x86_64-m32}-fedora13-linux-gnu.


Thanks,
Jan


gdb/
2010-06-26  Jan Kratochvil  <jan.kratochvil@redhat.com>

	Fix PR c++/11703 and PR gdb/1448.
	* c-exp.y (yylex) <last_was_coloncolon && first_was_coloncolon>: Add
	FIRST_ITER check.

gdb/testsuite/
2010-06-26  Jan Kratochvil  <jan.kratochvil@redhat.com>

	Test PR c++/11703 and PR gdb/1448.
	* gdb.cp/namespace.exp (whatis ::C::cOtherFileVar)
	(print ::C::cOtherFileVar)
	(print ::C::OtherFileClass::cOtherFileClassVar): Remove KFAIL for
	c++/11703.
	(ptype ::C::NestedClass): Remove KFAIL for gdb/1448.

--- a/gdb/c-exp.y
+++ b/gdb/c-exp.y
@@ -2553,7 +2553,7 @@ yylex (void)
     {
       token_and_value cc;
       memset (&cc, 0, sizeof (token_and_value));
-      if (first_was_coloncolon)
+      if (first_was_coloncolon && first_iter)
 	{
 	  yylval = cc.value;
 	  return COLONCOLON;
--- a/gdb/testsuite/gdb.cp/namespace.exp
+++ b/gdb/testsuite/gdb.cp/namespace.exp
@@ -170,10 +170,8 @@ gdb_test "break BBB::Class::xyzq" \
 gdb_test "whatis C::cOtherFileType" "type = short"
 gdb_test "whatis ::C::cOtherFileType" "type = short"
 gdb_test "whatis C::cOtherFileVar" "type = const C::cOtherFileType"
-setup_kfail "c++/11703" "*-*-*"
 gdb_test "whatis ::C::cOtherFileVar" "type = const C::cOtherFileType"
 gdb_test "print C::cOtherFileVar" "\\$\[0-9\].* = 319"
-setup_kfail "c++/11703" "*-*-*"
 gdb_test "print ::C::cOtherFileVar" "\\$\[0-9\].* = 319"
 
 if {[test_compiler_info {gcc-[0-3]-*}]
@@ -212,10 +210,6 @@ gdb_test_multiple $test $test {
 	    -re "\\$\[0-9\].* = 318\r\n$gdb_prompt $" {
 		pass $test2
 	    }
-	    -re "No symbol \"cOtherFileClassVar\" in current context\\.\r\n$gdb_prompt $" {
-		setup_kfail "c++/11703" "*-*-*"
-		fail $test2
-	    }
 	    -re "static field cOtherFileClassVar has been optimized out\r\n$gdb_prompt $" {
 		setup_kfail "c++/11702" "*-*-*"
 		fail $test2
@@ -262,7 +256,6 @@ gdb_test "ptype CClass::NestedClass" "type = (class C::CClass::NestedClass \{\r\
 gdb_test "ptype NestedClass" "No symbol \"NestedClass\" in current context."
 gdb_test "ptype ::C::CClass" "type = class C::CClass \{\r\n  public:\r\n    int x;\r\n\}"
 gdb_test "ptype ::C::CClass::NestedClass" "type = class C::CClass::NestedClass \{\r\n  public:\r\n    int y;\r\n\}"
-setup_kfail "gdb/1448" "*-*-*"
 gdb_test "ptype ::C::NestedClass" "No symbol \"NestedClass\" in namespace \"C\"."
 gdb_test "ptype C::CClass" "No symbol \"CClass\" in namespace \"C::C\"."
 gdb_test "ptype C::CClass::NestedClass" "No type \"CClass\" within class or namespace \"C::C\"."

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

* Re: [patch] Fix C++ leading :: (PR c++/11703 and PR gdb/1448)
  2010-06-26  8:22 [patch] Fix C++ leading :: (PR c++/11703 and PR gdb/1448) Jan Kratochvil
@ 2010-06-28 18:28 ` Tom Tromey
  2010-06-28 20:19   ` Jan Kratochvil
  0 siblings, 1 reply; 3+ messages in thread
From: Tom Tromey @ 2010-06-28 18:28 UTC (permalink / raw)
  To: Jan Kratochvil; +Cc: gdb-patches, Sami Wagiaalla

>>>>> "Jan" == Jan Kratochvil <jan.kratochvil@redhat.com> writes:

Jan> Maybe a more clear/straightforward conditional could be chosen than
Jan> `first_was_coloncolon && first_iter' to just really check
Jan> yylval.sval.ptr has been initialized.  But from some higher level
Jan> point of view the equivalent conditional `first_was_coloncolon &&
Jan> first_iter' makes sense there.

I agree.

Jan> 2010-06-26  Jan Kratochvil  <jan.kratochvil@redhat.com>
Jan> 	Fix PR c++/11703 and PR gdb/1448.
Jan> 	* c-exp.y (yylex) <last_was_coloncolon && first_was_coloncolon>: Add
Jan> 	FIRST_ITER check.

Jan> 2010-06-26  Jan Kratochvil  <jan.kratochvil@redhat.com>
Jan> 	Test PR c++/11703 and PR gdb/1448.
Jan> 	* gdb.cp/namespace.exp (whatis ::C::cOtherFileVar)
Jan> 	(print ::C::cOtherFileVar)
Jan> 	(print ::C::OtherFileClass::cOtherFileClassVar): Remove KFAIL for
Jan> 	c++/11703.
Jan> 	(ptype ::C::NestedClass): Remove KFAIL for gdb/1448.

This is ok.  Thanks for fixing this.

Tom

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

* Re: [patch] Fix C++ leading :: (PR c++/11703 and PR gdb/1448)
  2010-06-28 18:28 ` Tom Tromey
@ 2010-06-28 20:19   ` Jan Kratochvil
  0 siblings, 0 replies; 3+ messages in thread
From: Jan Kratochvil @ 2010-06-28 20:19 UTC (permalink / raw)
  To: Tom Tromey; +Cc: gdb-patches, Sami Wagiaalla

On Mon, 28 Jun 2010 20:28:27 +0200, Tom Tromey wrote:
> >>>>> "Jan" == Jan Kratochvil <jan.kratochvil@redhat.com> writes:
> Jan> 2010-06-26  Jan Kratochvil  <jan.kratochvil@redhat.com>
> Jan> 	Fix PR c++/11703 and PR gdb/1448.
> Jan> 	* c-exp.y (yylex) <last_was_coloncolon && first_was_coloncolon>: Add
> Jan> 	FIRST_ITER check.
> 
> Jan> 2010-06-26  Jan Kratochvil  <jan.kratochvil@redhat.com>
> Jan> 	Test PR c++/11703 and PR gdb/1448.
> Jan> 	* gdb.cp/namespace.exp (whatis ::C::cOtherFileVar)
> Jan> 	(print ::C::cOtherFileVar)
> Jan> 	(print ::C::OtherFileClass::cOtherFileClassVar): Remove KFAIL for
> Jan> 	c++/11703.
> Jan> 	(ptype ::C::NestedClass): Remove KFAIL for gdb/1448.
> 
> This is ok.  Thanks for fixing this.

Checked-in.  Simlified patches order so the gdb/testsuite/ change is reduced.


Thanks,
Jan


http://sourceware.org/ml/gdb-cvs/2010-06/msg00197.html

--- src/gdb/ChangeLog	2010/06/28 20:12:52	1.11942
+++ src/gdb/ChangeLog	2010/06/28 20:18:26	1.11943
@@ -1,5 +1,11 @@
 2010-06-28  Jan Kratochvil  <jan.kratochvil@redhat.com>
 
+	Fix PR c++/11703 and PR gdb/1448.
+	* c-exp.y (yylex) <last_was_coloncolon && first_was_coloncolon>: Add
+	FIRST_ITER check.
+
+2010-06-28  Jan Kratochvil  <jan.kratochvil@redhat.com>
+
 	Fix modification of cplus_struct_default.
 	* dwarf2read.c (dwarf2_add_member_fn) <no DW_AT_vtable_elem_location>:
 	Call ALLOCATE_CPLUS_STRUCT_TYPE.
--- src/gdb/c-exp.y	2010/05/07 14:46:25	1.75
+++ src/gdb/c-exp.y	2010/06/28 20:18:26	1.76
@@ -2553,7 +2553,7 @@
     {
       token_and_value cc;
       memset (&cc, 0, sizeof (token_and_value));
-      if (first_was_coloncolon)
+      if (first_was_coloncolon && first_iter)
 	{
 	  yylval = cc.value;
 	  return COLONCOLON;
--- src/gdb/testsuite/ChangeLog	2010/06/28 20:12:52	1.2359
+++ src/gdb/testsuite/ChangeLog	2010/06/28 20:18:26	1.2360
@@ -1,5 +1,11 @@
 2010-06-28  Jan Kratochvil  <jan.kratochvil@redhat.com>
 
+	Test PR c++/11703 and PR gdb/1448.
+	* gdb.cp/namespace.exp (ptype ::C::NestedClass): Remove KFAIL for
+	gdb/1448.
+
+2010-06-28  Jan Kratochvil  <jan.kratochvil@redhat.com>
+
 	* gdb.cp/virtbase.cc (class RTTI_base, class RTTI_data)
 	(main) <rtti_data>: New.
 	* gdb.cp/virtbase.exp (print rtti_data): New.
--- src/gdb/testsuite/gdb.cp/namespace.exp	2010/06/01 18:18:35	1.19
+++ src/gdb/testsuite/gdb.cp/namespace.exp	2010/06/28 20:18:27	1.20
@@ -192,7 +192,6 @@
 gdb_test "ptype NestedClass" "No symbol \"NestedClass\" in current context."
 gdb_test "ptype ::C::CClass" "type = class C::CClass \{\r\n  public:\r\n    int x;\r\n\}"
 gdb_test "ptype ::C::CClass::NestedClass" "type = class C::CClass::NestedClass \{\r\n  public:\r\n    int y;\r\n\}"
-setup_kfail "gdb/1448" "*-*-*"
 gdb_test "ptype ::C::NestedClass" "No symbol \"NestedClass\" in namespace \"C\"."
 gdb_test "ptype C::CClass" "No symbol \"CClass\" in namespace \"C::C\"."
 gdb_test "ptype C::CClass::NestedClass" "No type \"CClass\" within class or namespace \"C::C\"."

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

end of thread, other threads:[~2010-06-28 20:19 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-06-26  8:22 [patch] Fix C++ leading :: (PR c++/11703 and PR gdb/1448) Jan Kratochvil
2010-06-28 18:28 ` Tom Tromey
2010-06-28 20:19   ` Jan Kratochvil

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).