OSDN Git Service

PR debug/47283
authorjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 20 Jan 2011 16:40:36 +0000 (16:40 +0000)
committerjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 20 Jan 2011 16:40:36 +0000 (16:40 +0000)
* cfgexpand.c (expand_debug_expr): Instead of generating
(mem (debug_implicit_ptr)) for MEM_REFs use COMPONENT_REF
etc. handling.

* g++.dg/debug/pr47283.C: New test.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@169057 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/cfgexpand.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/debug/pr47283.C [new file with mode: 0644]

index d7d4eb4..af3cd28 100644 (file)
@@ -1,3 +1,10 @@
+2011-01-20  Jakub Jelinek  <jakub@redhat.com>
+
+       PR debug/47283
+       * cfgexpand.c (expand_debug_expr): Instead of generating
+       (mem (debug_implicit_ptr)) for MEM_REFs use COMPONENT_REF
+       etc. handling.
+
 2011-01-20  Richard Guenther  <rguenther@suse.de>
 
        PR middle-end/47370
index 81e988b..aeb2361 100644 (file)
@@ -2567,6 +2567,13 @@ expand_debug_expr (tree exp)
 
       if (TREE_CODE (exp) == MEM_REF)
        {
+         if (GET_CODE (op0) == DEBUG_IMPLICIT_PTR
+             || (GET_CODE (op0) == PLUS
+                 && GET_CODE (XEXP (op0, 0)) == DEBUG_IMPLICIT_PTR))
+           /* (mem (debug_implicit_ptr)) might confuse aliasing.
+              Instead just use get_inner_reference.  */
+           goto component_ref;
+
          op1 = expand_debug_expr (TREE_OPERAND (exp, 1));
          if (!op1 || !CONST_INT_P (op1))
            return NULL;
@@ -2605,6 +2612,7 @@ expand_debug_expr (tree exp)
 
       return op0;
 
+    component_ref:
     case ARRAY_REF:
     case ARRAY_RANGE_REF:
     case COMPONENT_REF:
index 0ca5517..cba5291 100644 (file)
@@ -1,5 +1,8 @@
 2011-01-20  Jakub Jelinek  <jakub@redhat.com>
 
+       PR debug/47283
+       * g++.dg/debug/pr47283.C: New test.
+
        PR testsuite/47371
        * gcc.target/i386/headmerge-1.c: Tighten up scan-assembler regex.
        * gcc.target/i386/headmerge-2.c: Likewise.
diff --git a/gcc/testsuite/g++.dg/debug/pr47283.C b/gcc/testsuite/g++.dg/debug/pr47283.C
new file mode 100644 (file)
index 0000000..dadbeff
--- /dev/null
@@ -0,0 +1,58 @@
+// PR debug/47283
+// { dg-do compile }
+
+template <typename T> inline const T &
+f1 (const T &a, const T &b)
+{
+  if (a < b)
+    return b;
+  return a;
+};
+
+struct A
+{
+  A (int w, int h) { a1 = w; }
+  A f2 (const A &) const;
+  int a1, a2;
+};
+
+inline A
+A::f2 (const A &x) const
+{
+  return A (f1 (a1, x.a1), f1 (a2, x.a2));
+};
+
+struct B
+{
+  A f3 () const;
+  void f4 (const A &) { b2 = 5 + b1; }
+  int b1, b2;
+};
+
+struct C
+{
+};
+
+struct D
+{
+  virtual C f5 (const C &) const;
+};
+
+struct E
+{
+  C f6 () const;
+  int f7 () const;
+  virtual B f8 (const C &) const;
+  A f9 () const;
+  virtual void f10 ();
+  struct F { D *h; } *d;
+};
+
+void
+E::f10 ()
+{
+  const C c = d->h->f5 (f6 ());
+  B b = f8 (c);
+  b.f4 (b.f3 ().f2 (f9 ()));
+  f7 ();
+}