From 5ba3ae6db5a599b3b8d3eaf500c47f447b36babf Mon Sep 17 00:00:00 2001 From: Richard Biener Date: Thu, 21 May 2015 13:23:41 +0000 Subject: [PATCH] re PR c++/66211 (Rvalue conversion in ternary operator causes internal compiler error) 2015-05-21 Richard Biener PR c++/66211 * match.pd: Guard pattern optimzing (int)(float)int conversions to apply only on GIMPLE. * g++.dg/conversion/pr66211.C: New testcase. * gcc.dg/tree-ssa/forwprop-18.c: Adjust. From-SVN: r223483 --- gcc/ChangeLog | 6 ++++++ gcc/match.pd | 3 ++- gcc/testsuite/ChangeLog | 6 ++++++ gcc/testsuite/g++.dg/conversion/pr66211.C | 11 +++++++++++ gcc/testsuite/gcc.dg/tree-ssa/forwprop-18.c | 8 ++++---- 5 files changed, 29 insertions(+), 5 deletions(-) create mode 100644 gcc/testsuite/g++.dg/conversion/pr66211.C diff --git a/gcc/ChangeLog b/gcc/ChangeLog index f4012b79536..af2225b1595 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2015-05-21 Richard Biener + + PR c++/66211 + * match.pd: Guard pattern optimzing (int)(float)int + conversions to apply only on GIMPLE. + 2015-05-21 Jeff Law * combine.c (find_split_point): Handle ASHIFT like MULT to encourage diff --git a/gcc/match.pd b/gcc/match.pd index 54500d91916..ce628531136 100644 --- a/gcc/match.pd +++ b/gcc/match.pd @@ -791,7 +791,8 @@ along with GCC; see the file COPYING3. If not see /* If we are converting an integer to a floating-point that can represent it exactly and back to an integer, we can skip the floating-point conversion. */ - (if (inside_int && inter_float && final_int && + (if (GIMPLE /* PR66211 */ + && inside_int && inter_float && final_int && (unsigned) significand_size (TYPE_MODE (inter_type)) >= inside_prec - !inside_unsignedp) (convert @0)))))) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 283644cdba2..e6814533848 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2015-05-21 Richard Biener + + PR c++/66211 + * g++.dg/conversion/pr66211.C: New testcase. + * gcc.dg/tree-ssa/forwprop-18.c: Adjust. + 2015-05-21 Jeff Law * gcc.target/hppa/shadd-2.c: New test. diff --git a/gcc/testsuite/g++.dg/conversion/pr66211.C b/gcc/testsuite/g++.dg/conversion/pr66211.C new file mode 100644 index 00000000000..49d2478888a --- /dev/null +++ b/gcc/testsuite/g++.dg/conversion/pr66211.C @@ -0,0 +1,11 @@ +// PR c++/66211 +// { dg-do compile } + +void f(int&){} + +int main() +{ + int x = 0; + double y = 1; + f(1 > 0 ? x : y); // { dg-error "from an rvalue" } +} diff --git a/gcc/testsuite/gcc.dg/tree-ssa/forwprop-18.c b/gcc/testsuite/gcc.dg/tree-ssa/forwprop-18.c index 2c4d120e999..b0445fd20fb 100644 --- a/gcc/testsuite/gcc.dg/tree-ssa/forwprop-18.c +++ b/gcc/testsuite/gcc.dg/tree-ssa/forwprop-18.c @@ -1,5 +1,5 @@ /* { dg-do compile } */ -/* { dg-options "-O -fdump-tree-forwprop1" } */ +/* { dg-options "-O -fdump-tree-cddce1" } */ signed char f1(signed char n) { @@ -19,6 +19,6 @@ signed char g2(unsigned long long n) return (float)n; } -/* { dg-final { scan-tree-dump-times "\\\(float\\\)" 2 "forwprop1" } } */ -/* { dg-final { scan-tree-dump-not "\\\(long double\\\)" "forwprop1" } } */ -/* { dg-final { cleanup-tree-dump "forwprop1" } } */ +/* { dg-final { scan-tree-dump-times "\\\(float\\\)" 2 "cddce1" } } */ +/* { dg-final { scan-tree-dump-not "\\\(long double\\\)" "cddce1" } } */ +/* { dg-final { cleanup-tree-dump "cddce1" } } */ -- 2.30.2