aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2008-08-29 20:48:30 +0200
committerJakub Jelinek <jakub@gcc.gnu.org>2008-08-29 20:48:30 +0200
commitb6b904bd616d3e1bb186db29c91172279cbd21b9 (patch)
treebfc0f5b20071fe951f174b64e91d8a12a392692c /gcc
parent714495cdcf2425b6aa9f3eac6bd010f3030ddd41 (diff)
downloadgcc-b6b904bd616d3e1bb186db29c91172279cbd21b9.zip
gcc-b6b904bd616d3e1bb186db29c91172279cbd21b9.tar.gz
gcc-b6b904bd616d3e1bb186db29c91172279cbd21b9.tar.bz2
dwarf2out.c (add_subscript_info): Stop on Fortran TYPE_STRING_FLAG types.
* dwarf2out.c (add_subscript_info): Stop on Fortran TYPE_STRING_FLAG types. (gen_array_type_die): Emit DW_TAG_string_type for Fortran character types. From-SVN: r139778
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog5
-rw-r--r--gcc/dwarf2out.c49
2 files changed, 50 insertions, 4 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index a2263cc..5517232 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,5 +1,10 @@
2008-08-29 Jakub Jelinek <jakub@redhat.com>
+ * dwarf2out.c (add_subscript_info): Stop on Fortran TYPE_STRING_FLAG
+ types.
+ (gen_array_type_die): Emit DW_TAG_string_type for Fortran character
+ types.
+
* dwarf2out.c (loc_by_reference): New function.
(add_location_or_const_value_attribute): Use it.
diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c
index 3291c3f..13eebbc 100644
--- a/gcc/dwarf2out.c
+++ b/gcc/dwarf2out.c
@@ -12027,6 +12027,9 @@ add_subscript_info (dw_die_ref type_die, tree type, bool collapse_p)
{
tree domain = TYPE_DOMAIN (type);
+ if (TYPE_STRING_FLAG (type) && is_fortran () && dimension_number > 0)
+ break;
+
/* Arrays come in three flavors: Unspecified bounds, fixed bounds,
and (in GNU C only) variable bounds. Handle all three forms
here. */
@@ -12560,7 +12563,40 @@ gen_array_type_die (tree type, dw_die_ref context_die)
bool collapse_nested_arrays = !is_ada ();
tree element_type;
-
+
+ /* Emit DW_TAG_string_type for Fortran character types (with kind 1 only, as
+ DW_TAG_string_type doesn't have DW_AT_type attribute). */
+ if (TYPE_STRING_FLAG (type)
+ && TREE_CODE (type) == ARRAY_TYPE
+ && is_fortran ()
+ && TYPE_MODE (TREE_TYPE (type)) == TYPE_MODE (char_type_node))
+ {
+ HOST_WIDE_INT size;
+
+ array_die = new_die (DW_TAG_string_type, scope_die, type);
+ add_name_attribute (array_die, type_tag (type));
+ equate_type_number_to_die (type, array_die);
+ size = int_size_in_bytes (type);
+ if (size >= 0)
+ add_AT_unsigned (array_die, DW_AT_byte_size, size);
+ else if (TYPE_DOMAIN (type) != NULL_TREE
+ && TYPE_MAX_VALUE (TYPE_DOMAIN (type)) != NULL_TREE
+ && DECL_P (TYPE_MAX_VALUE (TYPE_DOMAIN (type))))
+ {
+ tree szdecl = TYPE_MAX_VALUE (TYPE_DOMAIN (type));
+ dw_loc_descr_ref loc = loc_descriptor_from_tree (szdecl);
+
+ size = int_size_in_bytes (TREE_TYPE (szdecl));
+ if (loc && size > 0)
+ {
+ add_AT_loc (array_die, DW_AT_string_length, loc);
+ if (size != DWARF2_ADDR_SIZE)
+ add_AT_unsigned (array_die, DW_AT_byte_size, size);
+ }
+ }
+ return;
+ }
+
/* ??? The SGI dwarf reader fails for array of array of enum types
(e.g. const enum machine_mode insn_operand_mode[2][10]) unless the inner
array type comes before the outer array type. We thus call gen_type_die
@@ -12587,7 +12623,8 @@ gen_array_type_die (tree type, dw_die_ref context_die)
/* For Fortran multidimensional arrays use DW_ORD_col_major ordering. */
if (is_fortran ()
&& TREE_CODE (type) == ARRAY_TYPE
- && TREE_CODE (TREE_TYPE (type)) == ARRAY_TYPE)
+ && TREE_CODE (TREE_TYPE (type)) == ARRAY_TYPE
+ && !TYPE_STRING_FLAG (TREE_TYPE (type)))
add_AT_unsigned (array_die, DW_AT_ordering, DW_ORD_col_major);
#if 0
@@ -12615,8 +12652,12 @@ gen_array_type_die (tree type, dw_die_ref context_die)
element_type = TREE_TYPE (type);
if (collapse_nested_arrays)
while (TREE_CODE (element_type) == ARRAY_TYPE)
- element_type = TREE_TYPE (element_type);
-
+ {
+ if (TYPE_STRING_FLAG (element_type) && is_fortran ())
+ break;
+ element_type = TREE_TYPE (element_type);
+ }
+
#ifndef MIPS_DEBUGGING_INFO
gen_type_die (element_type, context_die);
#endif