From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 25660 invoked by alias); 30 Apr 2010 18:16:58 -0000 Received: (qmail 25642 invoked by uid 22791); 30 Apr 2010 18:16:57 -0000 X-SWARE-Spam-Status: No, hits=-6.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_HI,SPF_HELO_PASS,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; Fri, 30 Apr 2010 18:16:52 +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 o3UIGpw7002525 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Fri, 30 Apr 2010 14:16:51 -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 o3UIGn75017119 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Fri, 30 Apr 2010 14:16:50 -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 o3UIGmaZ010046; Fri, 30 Apr 2010 20:16:48 +0200 Received: (from jkratoch@localhost) by host0.dyn.jankratochvil.net (8.14.4/8.14.4/Submit) id o3UIGmi2010045; Fri, 30 Apr 2010 20:16:48 +0200 Date: Fri, 30 Apr 2010 18:16:00 -0000 From: Jan Kratochvil To: gdb-patches@sourceware.org Cc: Sami Wagiaalla Subject: [patch 2/3] Extend C++ import to support renaming even declarations Message-ID: <20100430181648.GB19190@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-08-17) 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-04/txt/msg01009.txt.bz2 Hi, the current C++ using-directive supports renaming of namespaces but it does not support renaming of specific imported declarations. This is fine as C++ does not support the latter. The Fortran patch 3/3 uses the existing FSF GDB C++ infrastructure, therefore it had to extend it. C++: using namespace A; Fortran: use A - namespace import, therefore not a "declaration" import - no renaming happens C++: using A::x; Fortran: use A, only: x - "declaration" import of the specific variable `x'. - no renaming happens namespace B = A; Fortran has no way to address non-local namespace/module. - namespace import, therefore not a "declaration" import - renaming "A" to "B" C++ cannot, it would be something like: using y = A::x; Fortran: use A, only y => x - "declaration" import of the specific variable `x'. - renaming "x" to "y" Therefore this patch implements the last case. It does not affect existing C++ functionality in the other 3 cases. No regressions on {x86_64,x86_64-m32,i686}-fedora12-linux-gnu for the whole patch series. Thanks, Jan 2010-04-30 Jan Kratochvil * cp-namespace.c (cp_lookup_symbol_imports): Support ALIAS for the CURRENT->DECLARATION case. --- a/gdb/cp-namespace.c +++ b/gdb/cp-namespace.c @@ -355,12 +355,14 @@ cp_lookup_symbol_imports (const char *scope, searched_cleanup = make_cleanup (reset_directive_searched, current); /* If there is an import of a single declaration, compare the imported - declaration with the sought out name. If there is a match pass - current->import_src as NAMESPACE to direct the search towards the - imported namespace. */ - if (current->declaration && strcmp (name, current->declaration) == 0) + declaration (after optional renaming by its alias) with the sought + out name. If there is a match pass current->import_src as NAMESPACE + to direct the search towards the imported namespace. */ + if (current->declaration + && strcmp (name, current->alias ? current->alias + : current->declaration) == 0) sym = cp_lookup_symbol_in_namespace (current->import_src, - name, + current->declaration, block, domain);