This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[patch] Fix C++ leading :: (PR c++/11703 and PR gdb/1448)


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\"."


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]