2004-01-23 David Carlton <carlton@kealia.com>

Patch for PR c++/1520:
	* dwarf2read.c (read_func_scope): Set processing_current_prefix
	properly if we have a specification die.
	(determine_prefix_aux): Rename from determine_prefix.
	(determine_prefix): Like the old determine_prefix, but never
	returns NULL.
This commit is contained in:
David Carlton 2004-01-23 22:41:28 +00:00
parent 5b828b6b4b
commit fdde2d8148
2 changed files with 68 additions and 2 deletions

View File

@ -1,3 +1,12 @@
2004-01-23 David Carlton <carlton@kealia.com>
Patch for PR c++/1520:
* dwarf2read.c (read_func_scope): Set processing_current_prefix
properly if we have a specification die.
(determine_prefix_aux): Rename from determine_prefix.
(determine_prefix): Like the old determine_prefix, but never
returns NULL.
2004-01-23 Theodore A. Roth <troth@openavr.org>
* avr-tdep.c: Update copyright.

View File

@ -774,6 +774,8 @@ static void read_type_die (struct die_info *, struct dwarf2_cu *);
static char *determine_prefix (struct die_info *die);
static char *determine_prefix_aux (struct die_info *die);
static char *typename_concat (const char *prefix, const char *suffix);
static char *class_name (struct die_info *die);
@ -2145,6 +2147,8 @@ read_func_scope (struct die_info *die, struct dwarf2_cu *cu)
struct die_info *child_die;
struct attribute *attr;
char *name;
const char *previous_prefix = processing_current_prefix;
struct cleanup *back_to = NULL;
name = dwarf2_linkage_name (die);
@ -2153,6 +2157,40 @@ read_func_scope (struct die_info *die, struct dwarf2_cu *cu)
if (name == NULL || !dwarf2_get_pc_bounds (die, &lowpc, &highpc, cu))
return;
if (cu_language == language_cplus)
{
struct die_info *spec_die = die_specification (die);
/* NOTE: carlton/2004-01-23: We have to be careful in the
presence of DW_AT_specification. For example, with GCC
3.4, given the code
namespace N {
void foo() {
// Definition of N::foo.
}
}
then we'll have a tree of DIEs like this:
1: DW_TAG_compile_unit
2: DW_TAG_namespace // N
3: DW_TAG_subprogram // declaration of N::foo
4: DW_TAG_subprogram // definition of N::foo
DW_AT_specification // refers to die #3
Thus, when processing die #4, we have to pretend that
we're in the context of its DW_AT_specification, namely
the contex of die #3. */
if (spec_die != NULL)
{
char *specification_prefix = determine_prefix (spec_die);
processing_current_prefix = specification_prefix;
back_to = make_cleanup (xfree, specification_prefix);
}
}
lowpc += baseaddr;
highpc += baseaddr;
@ -2203,6 +2241,10 @@ read_func_scope (struct die_info *die, struct dwarf2_cu *cu)
symbols go in the file symbol list. */
if (outermost_context_p ())
list_in_scope = &file_symbols;
processing_current_prefix = previous_prefix;
if (back_to != NULL)
do_cleanups (back_to);
}
/* Process all the DIES contained within a lexical block scope. Start
@ -5969,12 +6011,27 @@ read_type_die (struct die_info *die, struct dwarf2_cu *cu)
do_cleanups (back_to);
}
/* Return the name of the namespace/class that DIE is defined within,
or "" if we can't tell. The caller should xfree the result. */
/* NOTE: carlton/2004-01-23: See read_func_scope (and the comment
therein) for an example of how to use this function to deal with
DW_AT_specification. */
static char *
determine_prefix (struct die_info *die)
{
char *prefix = determine_prefix_aux (die);
return prefix ? prefix : xstrdup ("");
}
/* Return the name of the namespace/class that DIE is defined
within, or NULL if we can't tell. The caller should xfree the
result. */
static char *
determine_prefix (struct die_info *die)
determine_prefix_aux (struct die_info *die)
{
struct die_info *parent;
@ -5989,7 +6046,7 @@ determine_prefix (struct die_info *die)
}
else
{
char *parent_prefix = determine_prefix (parent);
char *parent_prefix = determine_prefix_aux (parent);
char *retval;
switch (parent->tag) {