From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 29204 invoked by alias); 30 Apr 2010 21:34:48 -0000 Received: (qmail 29167 invoked by uid 22791); 30 Apr 2010 21:34:40 -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 21:34:35 +0000 Received: from int-mx03.intmail.prod.int.phx2.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o3ULYX93029795 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Fri, 30 Apr 2010 17:34:33 -0400 Received: from host0.dyn.jankratochvil.net (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by int-mx03.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o3ULYUfD009787 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Fri, 30 Apr 2010 17:34:32 -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 o3ULYUqN020353; Fri, 30 Apr 2010 23:34:30 +0200 Received: (from jkratoch@localhost) by host0.dyn.jankratochvil.net (8.14.4/8.14.4/Submit) id o3ULYTXv020349; Fri, 30 Apr 2010 23:34:29 +0200 Date: Fri, 30 Apr 2010 21:34:00 -0000 From: Jan Kratochvil To: Tom Tromey Cc: gdb-patches@sourceware.org, Sami Wagiaalla Subject: Re: [patch 2/3] Extend C++ import to support renaming even declarations Message-ID: <20100430213429.GA20250@host0.dyn.jankratochvil.net> References: <20100430181648.GB19190@host0.dyn.jankratochvil.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: 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/msg01018.txt.bz2 On Fri, 30 Apr 2010 20:54:12 +0200, Tom Tromey wrote: > Please also update the documentation for struct using_direct to mention > this case. Right now the comment there indicates that alias==NULL in > all other cases. OK this way? (I understand the Fortran lines in the comment should be checked-in only with the patch 3/3 implementing them.) Thanks, Jan 2010-04-30 Jan Kratochvil * cp-namespace.c (cp_lookup_symbol_imports): Support ALIAS for the CURRENT->DECLARATION case. * cp-support.h (struct using_direct): Provide extended comment. --- 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); --- a/gdb/cp-support.h +++ b/gdb/cp-support.h @@ -37,19 +37,44 @@ struct type; struct demangle_component; /* This struct is designed to store data from using directives. It - says that names from namespace IMPORT_SRC should be visible within - namespace IMPORT_DEST. These form a linked list; NEXT is the next element - of the list. If the imported namespace has been aliased, ALIAS is set to a - string representing the alias. Otherwise, ALIAS is NULL. - Eg: - namespace C = A::B; - ALIAS = "C" - DECLARATION is the name of the imported declaration, if this import - statement represents one. - Eg: - using A::x; - Where x is variable in namespace A. DECLARATION is set to x. -*/ + says that names from namespace IMPORT_SRC should be visible within namespace + IMPORT_DEST. These form a linked list; NEXT is the next element of the + list. If the imported namespace or declaration has been aliased within the + IMPORT_DEST namespace, ALIAS is set to a string representing the alias. + Otherwise, ALIAS is NULL. DECLARATION is the name of the imported + declaration, if this import statement represents one. Otherwise DECLARATION + is NULL and this import statement represents a namespace. + + C++: using namespace A; + Fortran: use A + import_src = "A" + import_dest = local scope of the import statement even such as "" + alias = NULL + declaration = NULL + + C++: using A::x; + Fortran: use A, only: x + import_src = "A" + import_dest = local scope of the import statement even such as "" + alias = NULL + declaration = "x" + The declaration will get imported as import_dest::x. + + C++: namespace LOCALNS = A; + Fortran has no way to address non-local namespace/module. + import_src = "A" + import_dest = local scope of the import statement even such as "" + alias = "LOCALNS" + declaration = NULL + The namespace will get imported as the import_dest::LOCALNS namespace. + + C++ cannot express it, it would be something like: using localname = A::x; + Fortran: use A, only localname => x + import_src = "A" + import_dest = local scope of the import statement even such as "" + alias = "localname" + declaration = "x" + The declaration will get imported as localname or `import_dest`localname. */ struct using_direct {