From: Richard Guenther Date: Fri, 19 Jun 2009 21:44:24 +0000 (+0000) Subject: backport: [multiple changes] X-Git-Tag: releases/gcc-4.3.4~119 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7836d4264b2c0023398817242c1887ca04a5e150;p=thirdparty%2Fgcc.git backport: [multiple changes] 2009-06-19 Richard Guenther Backport from mainline: 2009-02-03 Andrew Pinski PR C++/36607 * convert.c (convert_to_integer): Treat OFFSET_TYPE like INTEGER_TYPE. * g++.dg/expr/cast10.C: New test. 2009-02-03 Jakub Jelinek PR target/35318 * function.c (match_asm_constraints_1): Skip over initial optional % in the constraint. * gcc.c-torture/compile/pr35318.c: New test. 2009-05-20 Jakub Jelinek PR middle-end/40204 * fold-const.c (fold_binary) : Avoid infinite recursion if build_int_cst_type returns the same INTEGER_CST as arg1. * gcc.c-torture/compile/pr40204.c: New test. From-SVN: r148730 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 4a23b66c46c5..ddda82545765 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,24 @@ +2009-06-19 Richard Guenther + + Backport from mainline: + 2009-02-03 Andrew Pinski + + PR C++/36607 + * convert.c (convert_to_integer): Treat OFFSET_TYPE like INTEGER_TYPE. + + 2009-05-20 Jakub Jelinek + + PR middle-end/40204 + * fold-const.c (fold_binary) : Avoid infinite + recursion if build_int_cst_type returns the same INTEGER_CST as + arg1. + + 2009-02-03 Jakub Jelinek + + PR target/35318 + * function.c (match_asm_constraints_1): Skip over + initial optional % in the constraint. + 2009-06-19 Richard Guenther Backport from mainline: diff --git a/gcc/convert.c b/gcc/convert.c index a9a22c52c53d..d5de95c1b46c 100644 --- a/gcc/convert.c +++ b/gcc/convert.c @@ -491,6 +491,7 @@ convert_to_integer (tree type, tree expr) case INTEGER_TYPE: case ENUMERAL_TYPE: case BOOLEAN_TYPE: + case OFFSET_TYPE: /* If this is a logical operation, which just returns 0 or 1, we can change the type of the expression. */ diff --git a/gcc/fold-const.c b/gcc/fold-const.c index a9010ebafd43..f3c6de44ffd4 100644 --- a/gcc/fold-const.c +++ b/gcc/fold-const.c @@ -11224,6 +11224,8 @@ fold_binary (enum tree_code code, tree type, tree op0, tree op1) if (prec < HOST_BITS_PER_WIDE_INT || newmask == ~(unsigned HOST_WIDE_INT) 0) { + tree newmaskt; + if (shift_type != TREE_TYPE (arg0)) { tem = fold_build2 (TREE_CODE (arg0), shift_type, @@ -11234,9 +11236,9 @@ fold_binary (enum tree_code code, tree type, tree op0, tree op1) } else tem = op0; - return fold_build2 (BIT_AND_EXPR, type, tem, - build_int_cst_type (TREE_TYPE (op1), - newmask)); + newmaskt = build_int_cst_type (TREE_TYPE (op1), newmask); + if (!tree_int_cst_equal (newmaskt, arg1)) + return fold_build2 (BIT_AND_EXPR, type, tem, newmaskt); } } } diff --git a/gcc/function.c b/gcc/function.c index e12ed0b2fbaf..d36919ce4fed 100644 --- a/gcc/function.c +++ b/gcc/function.c @@ -5712,6 +5712,9 @@ match_asm_constraints_1 (rtx insn, rtx *p_sets, int noutputs) char *end; int match, j; + if (*constraint == '%') + constraint++; + match = strtoul (constraint, &end, 10); if (end == constraint) continue; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 9680a75847ac..c7273969e6f1 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,21 @@ +2009-06-19 Richard Guenther + + Backport from mainline: + 2009-02-03 Andrew Pinski + + PR C++/36607 + * g++.dg/expr/cast10.C: New test. + + 2009-05-20 Jakub Jelinek + + PR middle-end/40204 + * gcc.c-torture/compile/pr40204.c: New test. + + 2009-02-03 Jakub Jelinek + + PR target/35318 + * gcc.c-torture/compile/pr35318.c: New test. + 2009-06-19 Richard Guenther Backport from mainline: diff --git a/gcc/testsuite/g++.dg/expr/cast10.C b/gcc/testsuite/g++.dg/expr/cast10.C new file mode 100644 index 000000000000..cd3e0fc3c271 --- /dev/null +++ b/gcc/testsuite/g++.dg/expr/cast10.C @@ -0,0 +1,10 @@ +// { dg-do compile } +// This used to error out because we would try to convert m to a short. + + +struct a {}; +void b() { + int a::*m; + a *c; + short p = reinterpret_cast(&(c->*m)) - reinterpret_cast(c); +} diff --git a/gcc/testsuite/gcc.c-torture/compile/pr35318.c b/gcc/testsuite/gcc.c-torture/compile/pr35318.c new file mode 100644 index 000000000000..85bb36269860 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/compile/pr35318.c @@ -0,0 +1,8 @@ +/* PR target/35318 */ + +void +foo () +{ + double x = 4, y; + __asm__ volatile ("" : "=r,r" (x), "=r,r" (y) : "%0,0" (x), "m,r" (8)); +} diff --git a/gcc/testsuite/gcc.c-torture/compile/pr40204.c b/gcc/testsuite/gcc.c-torture/compile/pr40204.c new file mode 100644 index 000000000000..3193284ff7a0 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/compile/pr40204.c @@ -0,0 +1,14 @@ +/* PR middle-end/40204 */ + +struct S +{ + unsigned int a : 4; + unsigned int b : 28; +} s; +char c; + +void +f (void) +{ + s.a = (c >> 4) & ~(1 << 4); +}