Fix accidentally removing the scope of variables when fixing them up

This is about bug
https://sourceware.org/bugzilla/show_bug.cgi?id=17652.  Some old DWARF
producers emit incomplete debug info for static data members.  We
currently detect this and fix the resulting constructed variables up.
During this fix up, it appears that we sometimes accidentally remove
the scope of some variables.  Fixed thus.

	* src/abg-dwarf-reader.cc (build_translation_unit_and_add_to_ir):
	During var decl fixup, remove the scope of a variable only when we
	are sure that we want to re-scope it.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
This commit is contained in:
Dodji Seketeli 2014-12-11 11:32:09 +01:00
parent e8a0fbaeee
commit 04abbd1d44

View File

@ -5037,17 +5037,19 @@ build_translation_unit_and_add_to_ir(read_context& ctxt,
// variable declaration DIE. Thus remove the global
// variable definition from its current non-class
// scope ...
remove_decl_from_scope(*v);
decl_base_sptr d;
if (d = lookup_var_decl_in_scope(mem_name,cl))
// This is the data member with the same name in cl.
// We need to flag it as static.
// We just need to flag it as static.
;
else
// In this case there is no data member with the
// same name in cl already. Let's add it there then
// ...
d = add_decl_to_scope(*v, cl);
{
// In this case there is no data member with the
// same name in cl already. Let's add it there then
// ...
remove_decl_from_scope(*v);
d = add_decl_to_scope(*v, cl);
}
assert(dynamic_pointer_cast<var_decl>(d));
// Let's flag the data member as static.