Commit bde2d108 by Jakub Jelinek Committed by Jakub Jelinek

re PR debug/41828 (DW_AT_name should not be present for anonymous aggregates)

	PR debug/41828
	* cp-lang.c (cxx_dwarf_name): Return NULL instead of
	<anonymous ...> for anonymous aggregate names.

	* dwarf2out.c (add_pubname, add_pubtype, generic_parameter_die,
	add_name_and_src_coords_attributes, gen_namespace_die,
	dwarf2out_set_name): Handle dwarf2_name returning NULL.

	* g++.dg/debug/dwarf2/anonname1.C: New test.

From-SVN: r153568
parent 20f2653e
2009-10-26 Jakub Jelinek <jakub@redhat.com>
PR debug/41828
* dwarf2out.c (add_pubname, add_pubtype, generic_parameter_die,
add_name_and_src_coords_attributes, gen_namespace_die,
dwarf2out_set_name): Handle dwarf2_name returning NULL.
2009-10-26 Nick Clifton <nickc@redhat.com> 2009-10-26 Nick Clifton <nickc@redhat.com>
* config.gcc: Add support for RX target. * config.gcc: Add support for RX target.
2009-10-26 Jakub Jelinek <jakub@redhat.com>
PR debug/41828
* cp-lang.c (cxx_dwarf_name): Return NULL instead of
<anonymous ...> for anonymous aggregate names.
2009-10-26 Jason Merrill <jason@redhat.com> 2009-10-26 Jason Merrill <jason@redhat.com>
PR c++/38796, Core issue 906 PR c++/38796, Core issue 906
......
...@@ -137,6 +137,9 @@ cxx_dwarf_name (tree t, int verbosity) ...@@ -137,6 +137,9 @@ cxx_dwarf_name (tree t, int verbosity)
{ {
gcc_assert (DECL_P (t)); gcc_assert (DECL_P (t));
if (DECL_NAME (t)
&& (ANON_AGGRNAME_P (DECL_NAME (t)) || LAMBDANAME_P (DECL_NAME (t))))
return NULL;
if (verbosity >= 2) if (verbosity >= 2)
return decl_as_string (t, return decl_as_string (t,
TFF_DECL_SPECIFIERS | TFF_UNQUALIFIED_NAME TFF_DECL_SPECIFIERS | TFF_UNQUALIFIED_NAME
......
...@@ -10781,7 +10781,11 @@ static void ...@@ -10781,7 +10781,11 @@ static void
add_pubname (tree decl, dw_die_ref die) add_pubname (tree decl, dw_die_ref die)
{ {
if (TREE_PUBLIC (decl)) if (TREE_PUBLIC (decl))
add_pubname_string (dwarf2_name (decl, 1), die); {
const char *name = dwarf2_name (decl, 1);
if (name)
add_pubname_string (name, die);
}
} }
/* Add a new entry to .debug_pubtypes if appropriate. */ /* Add a new entry to .debug_pubtypes if appropriate. */
...@@ -10811,7 +10815,11 @@ add_pubtype (tree decl, dw_die_ref die) ...@@ -10811,7 +10815,11 @@ add_pubtype (tree decl, dw_die_ref die)
} }
} }
else else
e.name = xstrdup (dwarf2_name (decl, 1)); {
e.name = dwarf2_name (decl, 1);
if (e.name)
e.name = xstrdup (e.name);
}
/* If we don't have a name for the type, there's no point in adding /* If we don't have a name for the type, there's no point in adding
it to the table. */ it to the table. */
...@@ -12359,7 +12367,8 @@ generic_parameter_die (tree parm, tree arg, ...@@ -12359,7 +12367,8 @@ generic_parameter_die (tree parm, tree arg,
/* The DW_AT_GNU_template_name attribute of the DIE must be set /* The DW_AT_GNU_template_name attribute of the DIE must be set
to the name of the argument. */ to the name of the argument. */
name = dwarf2_name (TYPE_P (arg) ? TYPE_NAME (arg) : arg, 1); name = dwarf2_name (TYPE_P (arg) ? TYPE_NAME (arg) : arg, 1);
add_AT_string (tmpl_die, DW_AT_GNU_template_name, name); if (name)
add_AT_string (tmpl_die, DW_AT_GNU_template_name, name);
} }
if (TREE_CODE (parm) == PARM_DECL) if (TREE_CODE (parm) == PARM_DECL)
...@@ -16464,7 +16473,9 @@ add_name_and_src_coords_attributes (dw_die_ref die, tree decl) ...@@ -16464,7 +16473,9 @@ add_name_and_src_coords_attributes (dw_die_ref die, tree decl)
decl_name = DECL_NAME (decl); decl_name = DECL_NAME (decl);
if (decl_name != NULL && IDENTIFIER_POINTER (decl_name) != NULL) if (decl_name != NULL && IDENTIFIER_POINTER (decl_name) != NULL)
{ {
add_name_attribute (die, dwarf2_name (decl, 0)); const char *name = dwarf2_name (decl, 0);
if (name)
add_name_attribute (die, name);
if (! DECL_ARTIFICIAL (decl)) if (! DECL_ARTIFICIAL (decl))
add_src_coords_attributes (die, decl); add_src_coords_attributes (die, decl);
...@@ -19222,7 +19233,11 @@ gen_namespace_die (tree decl, dw_die_ref context_die) ...@@ -19222,7 +19233,11 @@ gen_namespace_die (tree decl, dw_die_ref context_die)
context_die, decl); context_die, decl);
/* For Fortran modules defined in different CU don't add src coords. */ /* For Fortran modules defined in different CU don't add src coords. */
if (namespace_die->die_tag == DW_TAG_module && DECL_EXTERNAL (decl)) if (namespace_die->die_tag == DW_TAG_module && DECL_EXTERNAL (decl))
add_name_attribute (namespace_die, dwarf2_name (decl, 0)); {
const char *name = dwarf2_name (decl, 0);
if (name)
add_name_attribute (namespace_die, name);
}
else else
add_name_and_src_coords_attributes (namespace_die, decl); add_name_and_src_coords_attributes (namespace_die, decl);
if (DECL_EXTERNAL (decl)) if (DECL_EXTERNAL (decl))
...@@ -19910,23 +19925,28 @@ dwarf2out_set_name (tree decl, tree name) ...@@ -19910,23 +19925,28 @@ dwarf2out_set_name (tree decl, tree name)
{ {
dw_die_ref die; dw_die_ref die;
dw_attr_ref attr; dw_attr_ref attr;
const char *dname;
die = TYPE_SYMTAB_DIE (decl); die = TYPE_SYMTAB_DIE (decl);
if (!die) if (!die)
return; return;
dname = dwarf2_name (name, 0);
if (!dname)
return;
attr = get_AT (die, DW_AT_name); attr = get_AT (die, DW_AT_name);
if (attr) if (attr)
{ {
struct indirect_string_node *node; struct indirect_string_node *node;
node = find_AT_string (dwarf2_name (name, 0)); node = find_AT_string (dname);
/* replace the string. */ /* replace the string. */
attr->dw_attr_val.v.val_str = node; attr->dw_attr_val.v.val_str = node;
} }
else else
add_name_attribute (die, dwarf2_name (name, 0)); add_name_attribute (die, dname);
} }
/* Called by the final INSN scan whenever we see a direct function call. /* Called by the final INSN scan whenever we see a direct function call.
......
2009-10-26 Jakub Jelinek <jakub@redhat.com>
PR debug/41828
* g++.dg/debug/dwarf2/anonname1.C: New test.
2009-10-26 Jason Merrill <jason@redhat.com> 2009-10-26 Jason Merrill <jason@redhat.com>
PR c++/38796 PR c++/38796
......
// PR debug/41828
// { dg-do compile }
// { dg-options "-gdwarf-2 -dA" }
// { dg-final { scan-assembler-not "<anonymous" } }
// { dg-final { scan-assembler-not "\._\[0-9\]" } }
// { dg-final { scan-assembler-not "\$_\[0-9\]" } }
// { dg-final { scan-assembler-not "__anon_" } }
struct
{
union
{
struct
{
enum { a, b, c } x;
} s;
};
} x;
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment