This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH] Fix dwarf2out for DECL_BY_REFERENCE (PR debug/33537)
- 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: Wed, 31 Oct 2007 17:14:34 -0400
- Subject: [PATCH] Fix dwarf2out for DECL_BY_REFERENCE (PR debug/33537)
- Reply-to: Jakub Jelinek <jakub at redhat dot com>
Hi!
If a PARM_DECL or RESULT_DECL has DECL_BY_REFERENCE set by cp-gimplify.c,
then its type is a REFERENCE_TYPE of the real type as present in the
original sources. But for debuginfo we need to undo that and tell the
debugger the right type of the parameters or result.
Bootstrapped/regtested on x86_64-linux, tested on the testcase from bugzilla
using gdb. Ok for trunk?
2007-10-31 Jakub Jelinek <jakub@redhat.com>
PR debug/33537
* dwarf2out.c (gen_formal_parameter_die, gen_variable_die,
gen_decl_die): Use TREE_TYPE (TREE_TYPE (decl)) as type
rather than TREE_TYPE (decl) if DECL_BY_REFERENCE (decl).
--- gcc/dwarf2out.c.jj 2007-10-26 13:45:44.000000000 +0200
+++ gcc/dwarf2out.c 2007-10-31 17:19:38.000000000 +0100
@@ -11832,8 +11832,11 @@ gen_formal_parameter_die (tree node, dw_
add_abstract_origin_attribute (parm_die, origin);
else
{
+ tree type = TREE_TYPE (node);
add_name_and_src_coords_attributes (parm_die, node);
- add_type_attribute (parm_die, TREE_TYPE (node),
+ if (DECL_BY_REFERENCE (node))
+ type = TREE_TYPE (type);
+ add_type_attribute (parm_die, type,
TREE_READONLY (node),
TREE_THIS_VOLATILE (node),
context_die);
@@ -12437,8 +12439,14 @@ gen_variable_die (tree decl, dw_die_ref
}
else
{
+ tree type = TREE_TYPE (decl);
+ if ((TREE_CODE (decl) == PARM_DECL
+ || TREE_CODE (decl) == RESULT_DECL)
+ && DECL_BY_REFERENCE (decl))
+ type = TREE_TYPE (type);
+
add_name_and_src_coords_attributes (var_die, decl);
- add_type_attribute (var_die, TREE_TYPE (decl), TREE_READONLY (decl),
+ add_type_attribute (var_die, type, TREE_READONLY (decl),
TREE_THIS_VOLATILE (decl), context_die);
if (TREE_PUBLIC (decl))
@@ -13694,7 +13702,10 @@ gen_decl_die (tree decl, dw_die_ref cont
/* Output any DIEs that are needed to specify the type of this data
object. */
- gen_type_die (TREE_TYPE (decl), context_die);
+ if (TREE_CODE (decl) == RESULT_DECL && DECL_BY_REFERENCE (decl))
+ gen_type_die (TREE_TYPE (TREE_TYPE (decl)), context_die);
+ else
+ gen_type_die (TREE_TYPE (decl), context_die);
/* And its containing type. */
origin = decl_class_context (decl);
@@ -13728,7 +13739,10 @@ gen_decl_die (tree decl, dw_die_ref cont
break;
case PARM_DECL:
- gen_type_die (TREE_TYPE (decl), context_die);
+ if (DECL_BY_REFERENCE (decl))
+ gen_type_die (TREE_TYPE (TREE_TYPE (decl)), context_die);
+ else
+ gen_type_die (TREE_TYPE (decl), context_die);
gen_formal_parameter_die (decl, context_die);
break;
Jakub