This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH] Fix debuginfo for block local using N::x
- From: Jakub Jelinek <jakub at redhat dot com>
- To: Jason Merrill <jason at redhat dot com>
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Tue, 17 Mar 2009 17:06:50 +0100
- Subject: [PATCH] Fix debuginfo for block local using N::x
- Reply-to: Jakub Jelinek <jakub at redhat dot com>
Hi!
Block local using N::x; should be treated similarly to block local
using namespace N;, in particular the DIEs should be children of
the corresponding DW_TAG_lexical_block, not all queued among
DW_TAG_subprogram children.
Bootstrapped/regtested on x86_64-linux, ok for trunk?
2009-03-17 Jakub Jelinek <jakub@redhat.com>
* dwarf2out.c (dwarf2out_imported_module_or_decl_1): Allow
non-NAMESPACE_DECL IMPORTED_DECL_ASSOCIATED_DECL.
* name-lookup.c (cp_emit_debug_info_for_using): Emit USING_STMTs
instead of calling imported_module_or_decl debug hook if
building_stmt_tree ().
* cp-gimplify.c (cp_gimplify_expr): Don't assert the first operand
is a NAMESPACE_DECL.
--- gcc/cp/name-lookup.c.jj 2009-02-20 15:52:24.000000000 +0100
+++ gcc/cp/name-lookup.c 2009-03-17 09:23:22.000000000 +0100
@@ -5386,7 +5386,12 @@ cp_emit_debug_info_for_using (tree t, tr
/* FIXME: Handle TEMPLATE_DECLs. */
for (t = OVL_CURRENT (t); t; t = OVL_NEXT (t))
if (TREE_CODE (t) != TEMPLATE_DECL)
- (*debug_hooks->imported_module_or_decl) (t, NULL_TREE, context, false);
+ {
+ if (building_stmt_tree ())
+ add_stmt (build_stmt (USING_STMT, t));
+ else
+ (*debug_hooks->imported_module_or_decl) (t, NULL_TREE, context, false);
+ }
}
#include "gt-cp-name-lookup.h"
--- gcc/cp/cp-gimplify.c.jj 2009-03-17 08:41:52.000000000 +0100
+++ gcc/cp/cp-gimplify.c 2009-03-17 09:26:38.000000000 +0100
@@ -585,8 +585,7 @@ cp_gimplify_expr (tree *expr_p, gimple_s
if (block)
{
tree using_directive;
- gcc_assert (TREE_OPERAND (*expr_p,0)
- && NAMESPACE_DECL_CHECK (TREE_OPERAND (*expr_p, 0)));
+ gcc_assert (TREE_OPERAND (*expr_p, 0));
using_directive = make_node (IMPORTED_DECL);
TREE_TYPE (using_directive) = void_type_node;
--- gcc/dwarf2out.c.jj 2009-03-17 09:27:56.000000000 +0100
+++ gcc/dwarf2out.c 2009-03-17 09:33:57.000000000 +0100
@@ -15441,6 +15441,15 @@ dwarf2out_imported_module_or_decl_1 (tre
dw_die_ref imported_die = NULL;
dw_die_ref at_import_die;
+ if (TREE_CODE (decl) == IMPORTED_DECL)
+ {
+ xloc = expand_location (DECL_SOURCE_LOCATION (decl));
+ decl = IMPORTED_DECL_ASSOCIATED_DECL (decl);
+ gcc_assert (decl);
+ }
+ else
+ xloc = expand_location (input_location);
+
if (TREE_CODE (decl) == TYPE_DECL || TREE_CODE (decl) == CONST_DECL)
{
if (is_base_type (TREE_TYPE (decl)))
@@ -15458,18 +15467,6 @@ dwarf2out_imported_module_or_decl_1 (tre
gcc_assert (at_import_die);
}
}
- else if (TREE_CODE (decl) == IMPORTED_DECL)
- {
- tree imported_ns_decl = IMPORTED_DECL_ASSOCIATED_DECL (decl);
- /* IMPORTED_DECL nodes that are not imported namespace are just not
- supported yet. */
- gcc_assert (imported_ns_decl
- && TREE_CODE (imported_ns_decl) == NAMESPACE_DECL);
- at_import_die = lookup_decl_die (imported_ns_decl);
- if (!at_import_die)
- at_import_die = force_decl_die (imported_ns_decl);
- gcc_assert (at_import_die);
- }
else
{
at_import_die = lookup_decl_die (decl);
@@ -15493,10 +15490,7 @@ dwarf2out_imported_module_or_decl_1 (tre
}
}
- if (TREE_CODE (decl) == NAMESPACE_DECL
- || (TREE_CODE (decl) == IMPORTED_DECL
- && (TREE_CODE (IMPORTED_DECL_ASSOCIATED_DECL (decl))
- == NAMESPACE_DECL)))
+ if (TREE_CODE (decl) == NAMESPACE_DECL)
imported_die = new_die (DW_TAG_imported_module,
lexical_block_die,
lexical_block);
@@ -15505,10 +15499,6 @@ dwarf2out_imported_module_or_decl_1 (tre
lexical_block_die,
lexical_block);
- if (TREE_CODE (decl) == IMPORTED_DECL)
- xloc = expand_location (DECL_SOURCE_LOCATION (decl));
- else
- xloc = expand_location (input_location);
add_AT_file (imported_die, DW_AT_decl_file, lookup_filename (xloc.file));
add_AT_unsigned (imported_die, DW_AT_decl_line, xloc.line);
if (name)
Jakub