]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
trans-decl.c (gfc_build_qualified_array): Build non-flat array type for debug info...
authorJakub Jelinek <jakub@redhat.com>
Fri, 29 Aug 2008 18:43:57 +0000 (20:43 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Fri, 29 Aug 2008 18:43:57 +0000 (20:43 +0200)
* trans-decl.c (gfc_build_qualified_array): Build non-flat
array type for debug info purposes.

* dwarf2out.c (add_bound_info): If lookup_decl_die failed, try
loc_descriptor_from_tree_1.

From-SVN: r139774

gcc/ChangeLog
gcc/dwarf2out.c
gcc/fortran/ChangeLog
gcc/fortran/trans-decl.c

index 2bed3cd99765a1c81728d3b7e58b0ef6a9a3b13d..809bfd6161f97decbcb95555ba75406d82e33896 100644 (file)
@@ -1,5 +1,8 @@
 2008-08-29  Jakub Jelinek  <jakub@redhat.com>
 
+       * dwarf2out.c (add_bound_info): If lookup_decl_die failed, try
+       loc_descriptor_from_tree_1.
+
        PR fortran/29635
        PR fortran/23057
        * debug.h (struct gcc_debug_hooks): Add NAME and CHILD
index cc27e39dc9ac5a924a47025b019a857db7c2c4e6..4c6364cc3024d4fa71c305ecdc3cd157f9a62dea 100644 (file)
@@ -11934,6 +11934,7 @@ add_bound_info (dw_die_ref subrange_die, enum dwarf_attribute bound_attr, tree b
     case RESULT_DECL:
       {
        dw_die_ref decl_die = lookup_decl_die (bound);
+       dw_loc_descr_ref loc;
 
        /* ??? Can this happen, or should the variable have been bound
           first?  Probably it can, since I imagine that we try to create
@@ -11942,6 +11943,11 @@ add_bound_info (dw_die_ref subrange_die, enum dwarf_attribute bound_attr, tree b
           later parameter.  */
        if (decl_die != NULL)
          add_AT_die_ref (subrange_die, bound_attr, decl_die);
+       else
+         {
+           loc = loc_descriptor_from_tree_1 (bound, 0);
+           add_AT_location_description (subrange_die, bound_attr, loc);
+         }
        break;
       }
 
index a1a72e6122204802127b7ca5513068710b0a6859..55d452fdcdd424cc3a3d700c9d0af71d9bf0664c 100644 (file)
@@ -1,5 +1,8 @@
 2008-08-29  Jakub Jelinek  <jakub@redhat.com>
 
+       * trans-decl.c (gfc_build_qualified_array): Build non-flat
+       array type for debug info purposes.
+
        PR fortran/29635
        PR fortran/23057
        * f95-lang.c (gfc_init_ts): New function.
index 59b33cae33449547bf2efe8c00b42f506b272d18..54a1aa0159f704d9a12ffe18fc83a58e952a075a 100644 (file)
@@ -703,6 +703,50 @@ gfc_build_qualified_array (tree decl, gfc_symbol * sym)
       TYPE_DOMAIN (type) = range;
       layout_type (type);
     }
+
+  if (nest || write_symbols == NO_DEBUG)
+    return;
+
+  if (TYPE_NAME (type) != NULL_TREE
+      && GFC_TYPE_ARRAY_UBOUND (type, sym->as->rank - 1) != NULL_TREE
+      && TREE_CODE (GFC_TYPE_ARRAY_UBOUND (type, sym->as->rank - 1)) == VAR_DECL)
+    {
+      tree gtype = DECL_ORIGINAL_TYPE (TYPE_NAME (type));
+
+      for (dim = 0; dim < sym->as->rank - 1; dim++)
+       {
+         gcc_assert (TREE_CODE (gtype) == ARRAY_TYPE);
+         gtype = TREE_TYPE (gtype);
+       }
+      gcc_assert (TREE_CODE (gtype) == ARRAY_TYPE);
+      if (TYPE_MAX_VALUE (TYPE_DOMAIN (gtype)) == NULL)
+       TYPE_NAME (type) = NULL_TREE;
+    }
+
+  if (TYPE_NAME (type) == NULL_TREE)
+    {
+      tree gtype = TREE_TYPE (type), rtype, type_decl;
+
+      for (dim = sym->as->rank - 1; dim >= 0; dim--)
+       {
+         rtype = build_range_type (gfc_array_index_type,
+                                   GFC_TYPE_ARRAY_LBOUND (type, dim),
+                                   GFC_TYPE_ARRAY_UBOUND (type, dim));
+         gtype = build_array_type (gtype, rtype);
+         /* Ensure the bound variables aren't optimized out at -O0.  */
+         if (!optimize)
+           {
+             if (GFC_TYPE_ARRAY_LBOUND (type, dim)
+                 && TREE_CODE (GFC_TYPE_ARRAY_LBOUND (type, dim)) == VAR_DECL)
+               DECL_IGNORED_P (GFC_TYPE_ARRAY_LBOUND (type, dim)) = 0;
+             if (GFC_TYPE_ARRAY_UBOUND (type, dim)
+                 && TREE_CODE (GFC_TYPE_ARRAY_UBOUND (type, dim)) == VAR_DECL)
+               DECL_IGNORED_P (GFC_TYPE_ARRAY_UBOUND (type, dim)) = 0;
+           }
+       }
+      TYPE_NAME (type) = type_decl = build_decl (TYPE_DECL, NULL, gtype);
+      DECL_ORIGINAL_TYPE (type_decl) = gtype;
+    }
 }