Hi!

As mentioned in the PR, on the following testcase we ICE, because for
  # DEBUG D#2 => b
  # DEBUG D#1 => a[D#2].t
  # DEBUG c => D#1
during expansion we get the a[D#2].t added as MEM_EXPR of a MEM, and because
we can't mem_loc_descriptor that MEM (I'll post separately a trunk only
patch that fixes that in this case, but generally not all MEMs can be
represented in debug info), we try harder and try to use MEM_EXPR in
loc_list_from_tree, but that one ICEs on DEBUG_EXPR_DECL.  There is nothing
we can do for those at this point, debug_exprs are only useful to
var-tracking, so returning NULL is the only thing we can do for those.

Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk and 5.1?

2015-04-16  Jakub Jelinek  <ja...@redhat.com>

        PR debug/65771
        * dwarf2out.c (loc_list_from_tree): Return NULL
        for DEBUG_EXPR_DECL.

        * gcc.dg/debug/pr65771.c: New test.

--- gcc/dwarf2out.c.jj  2015-04-16 16:51:52.000000000 +0200
+++ gcc/dwarf2out.c     2015-04-16 16:57:28.866134980 +0200
@@ -14642,6 +14642,7 @@ loc_list_from_tree (tree loc, int want_a
 
     case TARGET_MEM_REF:
     case SSA_NAME:
+    case DEBUG_EXPR_DECL:
       return NULL;
 
     case COMPOUND_EXPR:
--- gcc/testsuite/gcc.dg/debug/pr65771.c.jj     2015-04-16 17:00:23.811328842 
+0200
+++ gcc/testsuite/gcc.dg/debug/pr65771.c        2015-04-16 17:00:13.000000000 
+0200
@@ -0,0 +1,15 @@
+/* PR debug/65771 */
+/* { dg-do link } */
+/* { dg-require-effective-target tls } */
+
+struct S { int s; int t; };
+__thread struct S a[10];
+int b;
+
+int
+main ()
+{
+  int c = a[b].t;
+  (void) c;
+  return 0;
+}

        Jakub

Reply via email to