aboutsummaryrefslogtreecommitdiff
path: root/gdb/cp-namespace.c
diff options
context:
space:
mode:
authorJan Kratochvil <jan.kratochvil@redhat.com>2011-06-29 22:05:16 +0000
committerJan Kratochvil <jan.kratochvil@redhat.com>2011-06-29 22:05:16 +0000
commit32019081a7af77c58fc3b4dbbf43a77e6f1a7c86 (patch)
tree9de855a84068a36b94476a2b5338e8559b6e6040 /gdb/cp-namespace.c
parent70c622a3d28b08cb57b8c8569658aa767241e161 (diff)
downloadgdb-32019081a7af77c58fc3b4dbbf43a77e6f1a7c86.zip
gdb-32019081a7af77c58fc3b4dbbf43a77e6f1a7c86.tar.gz
gdb-32019081a7af77c58fc3b4dbbf43a77e6f1a7c86.tar.bz2
gdb/
Fix non-only rename list for Fortran modules import. * cp-namespace.c (cp_scan_for_anonymous_namespaces): Adjust the cp_add_using_directive caller. (cp_add_using_directive): New parameter excludes, describe it. New variables ix and param. Compare if also excludes match. Allocate NEW with variable size, initialize EXCLUDES there. (cp_lookup_symbol_imports): New variable excludep, test current->EXCLUDES with it. * cp-support.h: Include vec.h. (struct using_direct): New field excludes, describe it. (DEF_VEC_P (const_char_ptr)): New. (cp_add_using_directive): New parameter excludes. * defs.h (const_char_ptr): New typedef. * dwarf2read.c (read_import_statement): New variables child_die, excludes and cleanups, read in excludes. (read_namespace): Adjust the cp_add_using_directive caller. gdb/testsuite/ Fix non-only rename list for Fortran modules import. * gdb.fortran/module.exp (print var_x, print var_y, print var_z): New tests. * gdb.fortran/module.f90 (module moduse): New. (program module): use moduse, test var_x, var_y and var_z.
Diffstat (limited to 'gdb/cp-namespace.c')
-rw-r--r--gdb/cp-namespace.c42
1 files changed, 38 insertions, 4 deletions
diff --git a/gdb/cp-namespace.c b/gdb/cp-namespace.c
index ff4d63e..68febcd 100644
--- a/gdb/cp-namespace.c
+++ b/gdb/cp-namespace.c
@@ -95,7 +95,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, NULL, NULL,
+ cp_add_using_directive (dest, src, NULL, NULL, NULL,
&SYMBOL_SYMTAB (symbol)->objfile->objfile_obstack);
}
/* The "+ 2" is for the "::". */
@@ -116,14 +116,17 @@ cp_scan_for_anonymous_namespaces (const struct symbol *symbol)
in the current scope. If ALIAS is NULL then the namespace is known
by its original name. DECLARATION is the name if the imported
varable if this is a declaration import (Eg. using A::x), otherwise
- it is NULL. The arguments are copied into newly allocated memory
- so they can be temporaries. */
+ it is NULL. EXCLUDES is a list of names not to import from an imported
+ module or NULL. The arguments are copied into newly allocated memory so
+ they can be temporaries. For EXCLUDES the VEC pointers are copied but the
+ pointed to characters are not copied. */
void
cp_add_using_directive (const char *dest,
const char *src,
const char *alias,
const char *declaration,
+ VEC (const_char_ptr) *excludes,
struct obstack *obstack)
{
struct using_direct *current;
@@ -133,6 +136,9 @@ cp_add_using_directive (const char *dest,
for (current = using_directives; current != NULL; current = current->next)
{
+ int ix;
+ const char *param;
+
if (strcmp (current->import_src, src) != 0)
continue;
if (strcmp (current->import_dest, dest) != 0)
@@ -148,11 +154,23 @@ cp_add_using_directive (const char *dest,
&& strcmp (declaration, current->declaration) != 0))
continue;
+ /* Compare the contents of EXCLUDES. */
+ for (ix = 0; VEC_iterate (const_char_ptr, excludes, ix, param); ix++)
+ if (current->excludes[ix] == NULL
+ || strcmp (param, current->excludes[ix]) != 0)
+ break;
+ if (ix < VEC_length (const_char_ptr, excludes)
+ || current->excludes[ix] != NULL)
+ continue;
+
/* Parameters exactly match CURRENT. */
return;
}
- new = OBSTACK_ZALLOC (obstack, struct using_direct);
+ new = obstack_alloc (obstack, (sizeof (*new)
+ + (VEC_length (const_char_ptr, excludes)
+ * sizeof (*new->excludes))));
+ memset (new, 0, sizeof (*new));
new->import_src = obsavestring (src, strlen (src), obstack);
new->import_dest = obsavestring (dest, strlen (dest), obstack);
@@ -164,6 +182,10 @@ cp_add_using_directive (const char *dest,
new->declaration = obsavestring (declaration, strlen (declaration),
obstack);
+ memcpy (new->excludes, VEC_address (const_char_ptr, excludes),
+ VEC_length (const_char_ptr, excludes) * sizeof (*new->excludes));
+ new->excludes[VEC_length (const_char_ptr, excludes)] = NULL;
+
new->next = using_directives;
using_directives = new;
}
@@ -332,6 +354,8 @@ cp_lookup_symbol_imports (const char *scope,
current != NULL;
current = current->next)
{
+ const char **excludep;
+
len = strlen (current->import_dest);
directive_match = (search_parents
? (strncmp (scope, current->import_dest,
@@ -377,6 +401,16 @@ cp_lookup_symbol_imports (const char *scope,
continue;
}
+ /* Do not follow CURRENT if NAME matches its EXCLUDES. */
+ for (excludep = current->excludes; *excludep; excludep++)
+ if (strcmp (name, *excludep) == 0)
+ break;
+ if (*excludep)
+ {
+ discard_cleanups (searched_cleanup);
+ continue;
+ }
+
if (current->alias != NULL
&& strcmp (name, current->alias) == 0)
/* If the import is creating an alias and the alias matches