2009-06-23 Sami Wagiaalla <swagiaal@redhat.com>

* dwarf2read.c (process_die): Handle import statements
       (DW_TAG_imported_declaration, case DW_TAG_imported_module)
       (read_import_statement): New.
       (read_func_scope): Update using_directives to point to current context
       (read_lexical_block_scope): Ditto.
       * cp-support.h: Added prototype for cp_add_using.
       * cp-namespace.c: Removed local context_stack.
       (cp_initialize_namespace): Deleted.
       (cp_finalize_namespace): Deleted.
       (cp_add_using_directive): Use using_directives instead of using_list.
       (cp_add_using): No longer static.
       * buildsym.h: Created global using_direct variable.
       Created using_direct variable in context_stack.
       * buildsym.c (finish_block): Set using directives for the block under
       construction.
       (start_symtab): Removed call to cp_initialize_namespace().
       (end_symtab): Removed call to cp_finalize_namespace().
       (push_context): Save and reset using_directives.
       * block.c (block_using): Return using directives for given
       block instead of static block.

2009-06-23  Sami Wagiaalla  <swagiaal@redhat.com>

       * gdb.cp/namespace-using.exp: New test.
       * gdb.cp/namespace-using.cc: New test.
This commit is contained in:
Sami Wagiaalla 2009-06-23 17:46:52 +00:00
parent ad068eabda
commit 27aa8d6aa0
10 changed files with 256 additions and 63 deletions

View file

@ -30,15 +30,7 @@
#include "dictionary.h"
#include "command.h"
#include "frame.h"
/* List of using directives that are active in the current file. */
static struct using_direct *using_list;
static struct using_direct *cp_add_using (const char *name,
unsigned int inner_len,
unsigned int outer_len,
struct using_direct *next);
#include "buildsym.h"
static struct using_direct *cp_copy_usings (struct using_direct *using,
struct obstack *obstack);
@ -78,31 +70,6 @@ static struct symbol *lookup_possible_namespace_symbol (const char *name);
static void maintenance_cplus_namespace (char *args, int from_tty);
/* Set up support for dealing with C++ namespace info in the current
symtab. */
void cp_initialize_namespace ()
{
using_list = NULL;
}
/* Add all the using directives we've gathered to the current symtab.
STATIC_BLOCK should be the symtab's static block; OBSTACK is used
for allocation. */
void
cp_finalize_namespace (struct block *static_block,
struct obstack *obstack)
{
if (using_list != NULL)
{
block_set_using (static_block,
cp_copy_usings (using_list, obstack),
obstack);
using_list = NULL;
}
}
/* Check to see if SYMBOL refers to an object contained within an
anonymous namespace; if so, add an appropriate using directive. */
@ -170,7 +137,7 @@ cp_add_using_directive (const char *name, unsigned int outer_length,
/* Has it already been added? */
for (current = using_list; current != NULL; current = current->next)
for (current = using_directives; current != NULL; current = current->next)
{
if ((strncmp (current->inner, name, inner_length) == 0)
&& (strlen (current->inner) == inner_length)
@ -178,8 +145,8 @@ cp_add_using_directive (const char *name, unsigned int outer_length,
return;
}
using_list = cp_add_using (name, inner_length, outer_length,
using_list);
using_directives = cp_add_using (name, inner_length, outer_length,
using_directives);
}
/* Record the namespace that the function defined by SYMBOL was
@ -237,7 +204,7 @@ cp_is_anonymous (const char *namespace)
using xmalloc. It copies the strings, so NAME can be a temporary
string. */
static struct using_direct *
struct using_direct *
cp_add_using (const char *name,
unsigned int inner_len,
unsigned int outer_len,