This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH] PR debug/38390
- From: Dodji Seketeli <dodji at redhat dot com>
- To: Gcc Patch List <gcc-patches at gcc dot gnu dot org>
- Cc: Jason Merrill <jason at redhat dot com>
- Date: Sun, 07 Dec 2008 23:15:42 +0100
- Subject: [PATCH] PR debug/38390
Hello,
In the example accompanying the attached patch, the
DW_AT_imported_module dwarf attribute is not generated, even though the
function f contains a using directive.
That is because no BIND_EXPR was generated for the function body,
because kept_level_p was returning false for the level of that function
body level. Changing kept_level_p to return true when a given level
contains a using directive seems to fix the problem.
A BIND_EXPR is now being generated for f. Does that create an
unacceptable overhead ?
FWIW, this patch passes regtests on trunk for the x86_64 architecture.
Thanks,
Dodji.
gcc/cp/ChangeLog:
2008-12-07 Dodji Seketeli <dodji@redhat.com>
PR debug/38390
* name-lookup.c (kept_level_p): Don't forget the case of levels
having using directives.
gcc/testsuite/ChangeLog:
2008-12-07 Dodji Seketeli <dodji@redhat.com>
PR debug/38390
* g++.dg/debug/dwarf2/imported-module-2.C: New test.
diff --git a/gcc/cp/name-lookup.c b/gcc/cp/name-lookup.c
index 0da373c..b5d14b3 100644
--- a/gcc/cp/name-lookup.c
+++ b/gcc/cp/name-lookup.c
@@ -1548,7 +1548,8 @@ kept_level_p (void)
return (current_binding_level->blocks != NULL_TREE
|| current_binding_level->keep
|| current_binding_level->kind == sk_cleanup
- || current_binding_level->names != NULL_TREE);
+ || current_binding_level->names != NULL_TREE
+ || current_binding_level->using_directives);
}
/* Returns the kind of the innermost scope. */
diff --git a/gcc/testsuite/g++.dg/debug/dwarf2/imported-module-2.C b/gcc/testsuite/g++.dg/debug/dwarf2/imported-module-2.C
new file mode 100644
index 0000000..8612897
--- /dev/null
+++ b/gcc/testsuite/g++.dg/debug/dwarf2/imported-module-2.C
@@ -0,0 +1,18 @@
+// Contributed by Dodji Seketeli <dodji@redhat.com>
+// Origin: PR debug/38390
+// { dg-do compile }
+// { dg-options "-g -dA" }
+// { dg-final { scan-assembler "DW_TAG_imported" } }
+
+namespace A
+{
+ int v;
+}
+
+int
+f ()
+{
+ using namespace A;
+ return v;
+}
+