OSDN Git Service

2006-07-05 Richard Guenther <rguenther@suse.de>
authorrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 5 Jul 2006 10:54:17 +0000 (10:54 +0000)
committerrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 5 Jul 2006 10:54:17 +0000 (10:54 +0000)
Andrew Pinski  <pinskia@gcc.gnu.org>

PR c++/27084
* cp-objcp-common.c (cxx_types_compatible_p): Ignore
top level qualifiers for pointer type comparisons.

* g++.dg/tree-ssa/copyprop-1.C: New testcase.

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

gcc/cp/ChangeLog
gcc/cp/cp-objcp-common.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/tree-ssa/copyprop-1.C [new file with mode: 0644]

index 896749e..d2c0562 100644 (file)
@@ -1,3 +1,10 @@
+2006-07-05  Richard Guenther  <rguenther@suse.de>
+       Andrew Pinski  <pinskia@gcc.gnu.org>
+
+       PR c++/27084
+       * cp-objcp-common.c (cxx_types_compatible_p): Ignore
+       top level qualifiers for pointer type comparisons.
+
 2006-07-01  Jason Merrill  <jason@redhat.com>
 
        PR c++/28215
index cb8369c..0b27abf 100644 (file)
@@ -179,7 +179,8 @@ cxx_types_compatible_p (tree x, tree y)
   if (POINTER_TYPE_P (x) && POINTER_TYPE_P (y)
       && TYPE_MODE (x) == TYPE_MODE (y)
       && TYPE_REF_CAN_ALIAS_ALL (x) == TYPE_REF_CAN_ALIAS_ALL (y)
-      && same_type_p (TREE_TYPE (x), TREE_TYPE (y)))
+      && same_type_ignoring_top_level_qualifiers_p (TREE_TYPE (x),
+                                                   TREE_TYPE (y)))
     return 1;
 
   return 0;
index a0ef642..02e6dd1 100644 (file)
@@ -1,3 +1,9 @@
+2006-07-05  Richard Guenther  <rguenther@suse.de>
+       Andrew Pinski  <pinskia@gcc.gnu.org>
+
+       PR c++/27084
+       * g++.dg/tree-ssa/copyprop-1.C: New testcase.
+
 2006-07-04  Paul Thomas  <pault@gcc.gnu.org>
 
        PR fortran/28174
diff --git a/gcc/testsuite/g++.dg/tree-ssa/copyprop-1.C b/gcc/testsuite/g++.dg/tree-ssa/copyprop-1.C
new file mode 100644 (file)
index 0000000..2be0469
--- /dev/null
@@ -0,0 +1,29 @@
+/* { dg-do compile } */
+/* { dg-options "-O -fdump-tree-dce2" } */
+
+/* Verify that we can eliminate the useless conversions to/from
+   const qualified pointer types
+     this_2 = o_1;
+     D.20003_4 = this_2->data_m;
+     this_5 = D.20003_4;
+     D.20005_6 = this_5->value;
+   copyprop should propagate o_1 and D.20003_4 to the loads of data_m
+   and value.  dce removes all traces of this.  */
+
+struct Data {
+  int get() const { return value; }
+  int value;
+};
+
+struct Object {
+  int operator[](int i) const { return data_m->get(); }
+  Data *data_m;
+};
+
+int foo(Object&o)
+{
+  return o[0];
+}
+
+/* { dg-final { scan-tree-dump-not ".* = \[^>;\]*;" "dce2" } } */
+/* { dg-final { cleanup-tree-dump "dce2" } } */