aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2010-03-03 08:02:37 +0100
committerJakub Jelinek <jakub@gcc.gnu.org>2010-03-03 08:02:37 +0100
commit0508bed7ffc2de0ccfebf7bde414a31f3062a21a (patch)
treeafb0e26639839ea21093a386287bf92eb2634e8d /gcc
parentdb51bb34401c8984f410afab38634daaaf68453c (diff)
downloadgcc-0508bed7ffc2de0ccfebf7bde414a31f3062a21a.zip
gcc-0508bed7ffc2de0ccfebf7bde414a31f3062a21a.tar.gz
gcc-0508bed7ffc2de0ccfebf7bde414a31f3062a21a.tar.bz2
re PR debug/43237 (Wrong DW_AT_upper_bound)
PR debug/43237 * dwarf2out.c (add_bound_info): If a decl bound doesn't have decl_die, fallthrough to default handling, just with want_address 0 instead of 2. For single element lists, add_AT_loc directly, otherwise create an artificial variable DIE and stick location list to it. * gcc.dg/debug/dwarf2/pr43237.c: New test. From-SVN: r157190
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog6
-rw-r--r--gcc/dwarf2out.c26
-rw-r--r--gcc/testsuite/ChangeLog3
-rw-r--r--gcc/testsuite/gcc.dg/debug/dwarf2/pr43237.c31
4 files changed, 54 insertions, 12 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 3e9a644..e31d206 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,5 +1,11 @@
2010-03-03 Jakub Jelinek <jakub@redhat.com>
+ PR debug/43237
+ * dwarf2out.c (add_bound_info): If a decl bound doesn't have decl_die,
+ fallthrough to default handling, just with want_address 0 instead of 2.
+ For single element lists, add_AT_loc directly, otherwise create an
+ artificial variable DIE and stick location list to it.
+
PR debug/43177
* var-tracking.c (loc_cmp): Don't assert VALUEs have the same mode.
(VAL_EXPR_HAS_REVERSE): Define.
diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c
index 2e8712f..2595119 100644
--- a/gcc/dwarf2out.c
+++ b/gcc/dwarf2out.c
@@ -16275,6 +16275,8 @@ add_comp_dir_attribute (dw_die_ref die)
static void
add_bound_info (dw_die_ref subrange_die, enum dwarf_attribute bound_attr, tree bound)
{
+ int want_address = 2;
+
switch (TREE_CODE (bound))
{
case ERROR_MARK:
@@ -16324,7 +16326,6 @@ 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_list_ref loc;
/* ??? Can this happen, or should the variable have been bound
first? Probably it can, since I imagine that we try to create
@@ -16332,14 +16333,13 @@ add_bound_info (dw_die_ref subrange_die, enum dwarf_attribute bound_attr, tree b
the list, and won't have created a forward reference to a
later parameter. */
if (decl_die != NULL)
- add_AT_die_ref (subrange_die, bound_attr, decl_die);
- else
{
- loc = loc_list_from_tree (bound, 0);
- add_AT_location_description (subrange_die, bound_attr, loc);
+ add_AT_die_ref (subrange_die, bound_attr, decl_die);
+ break;
}
- break;
+ want_address = 0;
}
+ /* FALLTHRU */
default:
{
@@ -16349,10 +16349,16 @@ add_bound_info (dw_die_ref subrange_die, enum dwarf_attribute bound_attr, tree b
dw_die_ref ctx, decl_die;
dw_loc_list_ref list;
- list = loc_list_from_tree (bound, 2);
+ list = loc_list_from_tree (bound, want_address);
if (list == NULL)
break;
+ if (single_element_loc_list_p (list))
+ {
+ add_AT_loc (subrange_die, bound_attr, list->expr);
+ break;
+ }
+
if (current_function_decl == 0)
ctx = comp_unit_die;
else
@@ -16361,11 +16367,7 @@ add_bound_info (dw_die_ref subrange_die, enum dwarf_attribute bound_attr, tree b
decl_die = new_die (DW_TAG_variable, ctx, bound);
add_AT_flag (decl_die, DW_AT_artificial, 1);
add_type_attribute (decl_die, TREE_TYPE (bound), 1, 0, ctx);
- if (list->dw_loc_next)
- add_AT_loc_list (decl_die, DW_AT_location, list);
- else
- add_AT_loc (decl_die, DW_AT_location, list->expr);
-
+ add_AT_location_description (decl_die, DW_AT_location, list);
add_AT_die_ref (subrange_die, bound_attr, decl_die);
break;
}
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 747dc6c..6e53f48 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,5 +1,8 @@
2010-03-03 Jakub Jelinek <jakub@redhat.com>
+ PR debug/43237
+ * gcc.dg/debug/dwarf2/pr43237.c: New test.
+
PR debug/43177
* gcc.dg/guality/pr43177.c: New test.
diff --git a/gcc/testsuite/gcc.dg/debug/dwarf2/pr43237.c b/gcc/testsuite/gcc.dg/debug/dwarf2/pr43237.c
new file mode 100644
index 0000000..21262c3
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/debug/dwarf2/pr43237.c
@@ -0,0 +1,31 @@
+/* PR debug/43237 */
+/* { dg-do compile } */
+/* { dg-options "-g -O2 -dA -fno-merge-debug-strings" } */
+
+struct S
+{
+ int *a;
+ int b;
+ int **c;
+ int d;
+};
+
+void foo (struct S *);
+void bar (struct S *);
+
+int
+baz (void)
+{
+ struct S s;
+ foo (&s);
+ {
+ int a[s.b];
+ int *c[s.d];
+ s.a = a;
+ s.c = c;
+ bar (&s);
+ }
+ return 0;
+}
+
+/* { dg-final { scan-assembler-not "LLST\[^\\r\\n\]*DW_AT_upper_bound" } } */