This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[patch] Emit variable as size attribute in debug info
- From: Eric Botcazou <ebotcazou at adacore dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: Mon, 9 Apr 2012 11:35:52 +0200
- Subject: [patch] Emit variable as size attribute in debug info
Hi,
in Ada record (structure) types can have a variable size and, in this case, the
debug info contains -1 as size attribute for the type. While the long term
plan is to support general expressions as size attribute, a small step forward
is to accept simple variables, which is an important subcase for GNAT.
Tested on x86_64-suse-linux, OK for the mainline?
2012-04-09 Eric Botcazou <ebotcazou@adacore.com>
* dwarf2out.c (add_byte_size_attribute) <RECORD_TYPE>: Handle variable
reference as size attribute.
--
Eric Botcazou
Index: dwarf2out.c
===================================================================
--- dwarf2out.c (revision 186176)
+++ dwarf2out.c (working copy)
@@ -15729,6 +15729,7 @@ add_subscript_info (dw_die_ref type_die,
static void
add_byte_size_attribute (dw_die_ref die, tree tree_node)
{
+ dw_die_ref decl_die;
unsigned size;
switch (TREE_CODE (tree_node))
@@ -15740,6 +15741,12 @@ add_byte_size_attribute (dw_die_ref die,
case RECORD_TYPE:
case UNION_TYPE:
case QUAL_UNION_TYPE:
+ if (TREE_CODE (TYPE_SIZE_UNIT (tree_node)) == VAR_DECL
+ && (decl_die = lookup_decl_die (TYPE_SIZE_UNIT (tree_node))))
+ {
+ add_AT_die_ref (die, DW_AT_byte_size, decl_die);
+ return;
+ }
size = int_size_in_bytes (tree_node);
break;
case FIELD_DECL: