Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Jan Kratochvil <jan.kratochvil@redhat.com>
To: gdb-patches@sourceware.org
Cc: Sami Wagiaalla <swagiaal@redhat.com>
Subject: [patch 2/3] Extend C++ import to support renaming even declarations
Date: Fri, 30 Apr 2010 18:16:00 -0000	[thread overview]
Message-ID: <20100430181648.GB19190@host0.dyn.jankratochvil.net> (raw)

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  <jan.kratochvil@redhat.com>

	* 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);
 


             reply	other threads:[~2010-04-30 18:16 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-04-30 18:16 Jan Kratochvil [this message]
2010-04-30 18:54 ` Tom Tromey
2010-04-30 21:34   ` Jan Kratochvil
2010-05-03 18:02     ` Tom Tromey
2010-05-03 20:11       ` Jan Kratochvil

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20100430181648.GB19190@host0.dyn.jankratochvil.net \
    --to=jan.kratochvil@redhat.com \
    --cc=gdb-patches@sourceware.org \
    --cc=swagiaal@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox