Blob Blame History Raw
From 678cbb7340d8edfa92ce6de931d8d4e9c3b86c06 Mon Sep 17 00:00:00 2001
From: Jan Kratochvil <jan.kratochvil@redhat.com>
Date: Fri, 18 Feb 2011 00:46:12 +0100
Subject: [PATCH 2/2] Fix the remaining two FAILing subrange testcases.

---
 gdb/dwarf2read.c |   14 ++++++++------
 gdb/eval.c       |    5 ++++-
 2 files changed, 12 insertions(+), 7 deletions(-)

diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
index 89d15d1..a9099be 100644
--- a/gdb/dwarf2read.c
+++ b/gdb/dwarf2read.c
@@ -7416,6 +7416,14 @@ read_array_type (struct die_info *die, struct dwarf2_cu *cu)
     for (i = ndim - 1; i >= 0; i--)
       type = create_single_array_dimension (type, range_types[i], die, cu);
 
+  /* Data locations should be set only for the outermost dimension as they
+     would be confusing for the dereferenced offset on the inner ones.  */
+  attr = dwarf2_attr (die, DW_AT_data_location, cu);
+  if (attr_form_is_block (attr))
+    TYPE_DATA_LOCATION_DWARF_BLOCK (type)
+      = dwarf2_attr_to_locexpr_baton (attr, cu);
+  gdb_assert (!TYPE_DATA_LOCATION_IS_ADDR (type));
+
   /* Understand Dwarf2 support for vector types (like they occur on
      the PowerPC w/ AltiVec).  Gcc just adds another attribute to the
      array type.  This is not part of the Dwarf2/3 standard yet, but a
@@ -15072,12 +15080,6 @@ fetch_die_type_attrs (struct die_info *die, struct type *type,
 {
   struct attribute *attr;
 
-  attr = dwarf2_attr (die, DW_AT_data_location, cu);
-  if (attr_form_is_block (attr))
-    TYPE_DATA_LOCATION_DWARF_BLOCK (type) = dwarf2_attr_to_locexpr_baton (attr,
-									  cu);
-  gdb_assert (!TYPE_DATA_LOCATION_IS_ADDR (type));
-
   attr = dwarf2_attr (die, DW_AT_allocated, cu);
   if (attr_form_is_block (attr))
     TYPE_ALLOCATED (type) = dwarf2_attr_to_locexpr_baton (attr, cu);
diff --git a/gdb/eval.c b/gdb/eval.c
index 6f37f2c..f4ccc89 100644
--- a/gdb/eval.c
+++ b/gdb/eval.c
@@ -566,7 +566,10 @@ value_f90_subarray (struct value *array, struct expression *exp, int *pos,
       TYPE_DATA_LOCATION_DWARF_BLOCK (type) = NULL;
     }
   else
-    value_byte_address = value_address (array);
+    {
+      gdb_assert (TYPE_DATA_LOCATION_DWARF_BLOCK (type) == NULL);
+      value_byte_address = value_address (array);
+    }
 
   new_array_type = type;
 
-- 
1.7.4