From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 22819 invoked by alias); 26 Jun 2010 08:22:15 -0000 Received: (qmail 22809 invoked by uid 22791); 26 Jun 2010 08:22:14 -0000 X-SWARE-Spam-Status: No, hits=-5.8 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_HI,SPF_HELO_PASS,TW_YY,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sat, 26 Jun 2010 08:22:10 +0000 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o5Q8M8mc016912 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Sat, 26 Jun 2010 04:22:08 -0400 Received: from host0.dyn.jankratochvil.net (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o5Q8M6qW020648 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Sat, 26 Jun 2010 04:22:08 -0400 Received: from host0.dyn.jankratochvil.net (localhost [127.0.0.1]) by host0.dyn.jankratochvil.net (8.14.4/8.14.4) with ESMTP id o5Q8M6qT030812; Sat, 26 Jun 2010 10:22:06 +0200 Received: (from jkratoch@localhost) by host0.dyn.jankratochvil.net (8.14.4/8.14.4/Submit) id o5Q8M5MX030810; Sat, 26 Jun 2010 10:22:05 +0200 Date: Sat, 26 Jun 2010 08:22:00 -0000 From: Jan Kratochvil To: gdb-patches@sourceware.org Cc: Sami Wagiaalla Subject: [patch] Fix C++ leading :: (PR c++/11703 and PR gdb/1448) Message-ID: <20100626082205.GA30439@host0.dyn.jankratochvil.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.20 (2009-12-10) X-IsSubscribed: yes Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2010-06/txt/msg00610.txt.bz2 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 Fix PR c++/11703 and PR gdb/1448. * c-exp.y (yylex) : Add FIRST_ITER check. gdb/testsuite/ 2010-06-26 Jan Kratochvil 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\"."