From: Richard Guenther Date: Tue, 27 Apr 2010 12:15:53 +0000 (+0000) Subject: backport: re PR tree-optimization/38564 (Revision 142662 caused ICE in insert_into_pr... X-Git-Tag: releases/gcc-4.3.5~74 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b8d26a68da98838776945fd86137f339e7ebf3bd;p=thirdparty%2Fgcc.git backport: re PR tree-optimization/38564 (Revision 142662 caused ICE in insert_into_preds_of_block) 2010-04-27 Richard Guenther Backport from mainline 2008-12-29 Richard Guenther 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 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 3009a5d2284f..f1c2d133d9b8 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,12 @@ +2010-04-27 Richard Guenther + + PR c++/40561 + Backport from mainline + 2008-12-29 Richard Guenther + + PR middle-end/38564 + * fold-const.c (fold_comparison): Use the correct result type. + 2010-04-27 Richard Guenther Backport from mainline: diff --git a/gcc/fold-const.c b/gcc/fold-const.c index 76d8adc00b9f..e75b2b25c5e3 100644 --- a/gcc/fold-const.c +++ b/gcc/fold-const.c @@ -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:; } } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 8c5e53148d00..b43e4b20997c 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,13 @@ +2010-04-27 Richard Guenther + + PR c++/40561 + Backport from mainline + 2008-12-29 Richard Guenther + + PR middle-end/38564 + * gcc.c-torture/compile/pr38564.c: New testcase. + * g++.dg/other/pr40561.C: Likewise. + 2010-04-27 Richard Guenther 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 index 000000000000..c94dfa4bd625 --- /dev/null +++ b/gcc/testsuite/g++.dg/other/pr40561.C @@ -0,0 +1,38 @@ +// { dg-do compile } + +#include + +class SyAccess; +class VamsBase +{ + public: + virtual ~VamsBase(void); +}; + +class VamsFnct : public VamsBase +{ + public: + ~VamsFnct(void); + std::set getNullDependencies(void) const + { return std::set(); + } +}; + +class VamsFnctSystem:public VamsFnct +{ public: + VamsFnctSystem( + const bool _bPassDependencies); +}; + +template< std::set (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 index 000000000000..de365cc1f55c --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/compile/pr38564.c @@ -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); +}