aboutsummaryrefslogtreecommitdiff
path: root/gdb/cp-namespace.c
diff options
context:
space:
mode:
authorSami Wagiaalla <swagiaal@redhat.com>2010-02-05 19:03:42 +0000
committerSami Wagiaalla <swagiaal@redhat.com>2010-02-05 19:03:42 +0000
commit82856980164673e7d71180ff67f14d96190b2b3c (patch)
tree5ad5cd6466108a37cc206930dd6b35dd657cc15a /gdb/cp-namespace.c
parent1beeb6866d4f102b1a205391056e7ba4aa59fdd8 (diff)
downloadgdb-82856980164673e7d71180ff67f14d96190b2b3c.zip
gdb-82856980164673e7d71180ff67f14d96190b2b3c.tar.gz
gdb-82856980164673e7d71180ff67f14d96190b2b3c.tar.bz2
2010-02-05 Sami Wagiaalla <swagiaal@redhat.com>
PR c++/7935: * gdb.cp/namespace-using.exp: Removed kfail; bug has been fixed. 2010-02-05 Sami Wagiaalla <swagiaal@redhat.com> PR c++/7935: * cp-support.h: Added char* alias element to using_direct data struct. (cp_add_using): Added char* alias argument. (cp_add_using_directive): Ditto. * cp-namespace.c: Updated with the above changes. (cp_lookup_symbol_imports): Check for aliases. * dwarf2read.c (read_import_statement): Figure out local alias for the import and pass it on to cp_add_using. (read_namespace): Pass alias argument to cp_add_using.
Diffstat (limited to 'gdb/cp-namespace.c')
-rw-r--r--gdb/cp-namespace.c47
1 files changed, 35 insertions, 12 deletions
diff --git a/gdb/cp-namespace.c b/gdb/cp-namespace.c
index 8ca9c20..5e894d4 100644
--- a/gdb/cp-namespace.c
+++ b/gdb/cp-namespace.c
@@ -117,7 +117,7 @@ cp_scan_for_anonymous_namespaces (const struct symbol *symbol)
anonymous namespace. So add symbols in it to the
namespace given by the previous component if there is
one, or to the global namespace if there isn't. */
- cp_add_using_directive (dest, src);
+ cp_add_using_directive (dest, src, NULL);
}
/* The "+ 2" is for the "::". */
previous_component = next_component + 2;
@@ -132,7 +132,7 @@ cp_scan_for_anonymous_namespaces (const struct symbol *symbol)
has already been added, don't add it twice. */
void
-cp_add_using_directive (const char *dest, const char *src)
+cp_add_using_directive (const char *dest, const char *src, const char *alias)
{
struct using_direct *current;
struct using_direct *new;
@@ -146,7 +146,7 @@ cp_add_using_directive (const char *dest, const char *src)
return;
}
- using_directives = cp_add_using (dest, src, using_directives);
+ using_directives = cp_add_using (dest, src, alias, using_directives);
}
@@ -198,8 +198,9 @@ cp_is_anonymous (const char *namespace)
!= NULL);
}
-/* Create a new struct using direct which imports the namespace SRC
- into the scope DEST.
+/* Create a new struct using direct which imports the namespace SRC into the
+ scope DEST. ALIAS is the name of the imported namespace in the current
+ scope. If ALIAS is NULL then the namespace is known by its original name.
Set its next member in the linked list to NEXT; allocate all memory
using xmalloc. It copies the strings, so NAME can be a temporary
string. */
@@ -207,6 +208,7 @@ cp_is_anonymous (const char *namespace)
struct using_direct *
cp_add_using (const char *dest,
const char *src,
+ const char *alias,
struct using_direct *next)
{
struct using_direct *retval;
@@ -214,6 +216,12 @@ cp_add_using (const char *dest,
retval = xmalloc (sizeof (struct using_direct));
retval->import_src = savestring (src, strlen(src));
retval->import_dest = savestring (dest, strlen(dest));
+
+ if (alias != NULL)
+ retval->alias = savestring (alias, strlen (alias));
+ else
+ retval->alias = NULL;
+
retval->next = next;
retval->searched = 0;
@@ -344,13 +352,28 @@ cp_lookup_symbol_imports (const char *scope,
current->searched = 1;
searched_cleanup = make_cleanup (reset_directive_searched, current);
- sym = cp_lookup_symbol_namespace (current->import_src,
- name,
- linkage_name,
- block,
- domain,
- 0);
-
+ if (current->alias != NULL && strcmp (name, current->alias) == 0)
+ /* If the import is creating an alias and the alias matches the
+ sought name. Pass current->import_src as the NAME to direct the
+ search towards the aliased namespace. */
+ {
+ sym = cp_lookup_symbol_in_namespace (scope,
+ current->import_src,
+ linkage_name,
+ block,
+ domain);
+ }
+ else if (current->alias == NULL)
+ {
+ /* If this import statement creates no alias, pass current->inner as
+ NAMESPACE to direct the search towards the imported namespace. */
+ sym = cp_lookup_symbol_imports (current->import_src,
+ name,
+ linkage_name,
+ block,
+ domain,
+ 0);
+ }
current->searched = 0;
discard_cleanups (searched_cleanup);