]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
backport: re PR tree-optimization/38564 (Revision 142662 caused ICE in insert_into_pr...
authorRichard Guenther <rguenther@suse.de>
Tue, 27 Apr 2010 12:15:53 +0000 (12:15 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Tue, 27 Apr 2010 12:15:53 +0000 (12:15 +0000)
2010-04-27  Richard Guenther  <rguenther@suse.de>

Backport from mainline
2008-12-29  Richard Guenther  <rguenther@suse.de>

PR middle-end/38564
* fold-const.c (fold_comparison): Use the correct result type.

* gcc.c-torture/compile/pr38564.c: New testcase.
* g++.dg/other/pr40561.C: Likewise.

From-SVN: r158782

gcc/ChangeLog
gcc/fold-const.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/other/pr40561.C [new file with mode: 0644]
gcc/testsuite/gcc.c-torture/compile/pr38564.c [new file with mode: 0644]

index 3009a5d2284f92772fadb12df959c4d3730994a4..f1c2d133d9b8c45982720c65db1bf584a372dc65 100644 (file)
@@ -1,3 +1,12 @@
+2010-04-27  Richard Guenther  <rguenther@suse.de>
+
+       PR c++/40561
+       Backport from mainline
+       2008-12-29  Richard Guenther  <rguenther@suse.de>
+
+       PR middle-end/38564
+       * fold-const.c (fold_comparison): Use the correct result type.
+
 2010-04-27  Richard Guenther  <rguenther@suse.de>
 
        Backport from mainline:
index 76d8adc00b9f3a4bce2c95ba9b968b4c0c719ffa..e75b2b25c5e3785940e7dbe882a36fcdbe9fa6b1 100644 (file)
@@ -8954,17 +8954,17 @@ fold_comparison (enum tree_code code, tree type, tree op0, tree op1)
              switch (code)
                {
                case EQ_EXPR:
-                 return build_int_cst (boolean_type_node, bitpos0 == bitpos1);
+                 return constant_boolean_node (bitpos0 == bitpos1, type);
                case NE_EXPR:
-                 return build_int_cst (boolean_type_node, bitpos0 != bitpos1);
+                 return constant_boolean_node (bitpos0 != bitpos1, type);
                case LT_EXPR:
-                 return build_int_cst (boolean_type_node, bitpos0 < bitpos1);
+                 return constant_boolean_node (bitpos0 < bitpos1, type);
                case LE_EXPR:
-                 return build_int_cst (boolean_type_node, bitpos0 <= bitpos1);
+                 return constant_boolean_node (bitpos0 <= bitpos1, type);
                case GE_EXPR:
-                 return build_int_cst (boolean_type_node, bitpos0 >= bitpos1);
+                 return constant_boolean_node (bitpos0 >= bitpos1, type);
                case GT_EXPR:
-                 return build_int_cst (boolean_type_node, bitpos0 > bitpos1);
+                 return constant_boolean_node (bitpos0 > bitpos1, type);
                default:;
                }
            }
index 8c5e53148d003c4f881ab463f9eb176d53264152..b43e4b20997c161e1f1106c72b8362559788d1b1 100644 (file)
@@ -1,3 +1,13 @@
+2010-04-27  Richard Guenther  <rguenther@suse.de>
+
+       PR c++/40561
+       Backport from mainline
+       2008-12-29  Richard Guenther  <rguenther@suse.de>
+
+       PR middle-end/38564
+       * gcc.c-torture/compile/pr38564.c: New testcase.
+       * g++.dg/other/pr40561.C: Likewise.
+
 2010-04-27  Richard Guenther  <rguenther@suse.de>
 
        Backport from mainline:
diff --git a/gcc/testsuite/g++.dg/other/pr40561.C b/gcc/testsuite/g++.dg/other/pr40561.C
new file mode 100644 (file)
index 0000000..c94dfa4
--- /dev/null
@@ -0,0 +1,38 @@
+// { dg-do compile }
+
+#include <set>
+
+class SyAccess;
+class VamsBase 
+{
+       public:
+       virtual ~VamsBase(void);
+};
+
+class VamsFnct : public VamsBase 
+{      
+       public:
+       ~VamsFnct(void);
+       std::set<SyAccess*> getNullDependencies(void) const
+       {       return std::set<SyAccess*>();
+       }
+};
+
+class VamsFnctSystem:public VamsFnct
+{      public:
+       VamsFnctSystem(
+               const bool _bPassDependencies);
+};
+
+template< std::set<SyAccess*> (VamsFnct::*__GET_DEP__)(void) const >
+class VamsSystemFunction:public VamsFnctSystem
+{      public:
+       VamsSystemFunction()
+           :VamsFnctSystem(
+               __GET_DEP__ != &VamsFnct::getNullDependencies
+               )
+       {
+       }
+};
+
+VamsSystemFunction<&VamsFnct::getNullDependencies> s;
diff --git a/gcc/testsuite/gcc.c-torture/compile/pr38564.c b/gcc/testsuite/gcc.c-torture/compile/pr38564.c
new file mode 100644 (file)
index 0000000..de365cc
--- /dev/null
@@ -0,0 +1,22 @@
+struct S
+{
+  struct S *n, *p;
+} *s;
+
+void bar (void *);
+
+int
+foo (int x)
+{
+  struct S p = { &p, &p };
+  int i;
+  for (i = 0; i < x; i++)
+    bar (s);
+  return p.n == &p;
+}
+
+int dialog_calendar(int state)
+{
+  int *obj = (state == 1 ? &state : 0);
+  return (obj == &state);
+}