From 226c5ce4507f3f389f52fae18d410773d4674046 Mon Sep 17 00:00:00 2001 From: rguenth Date: Fri, 4 Apr 2008 11:29:11 +0000 Subject: [PATCH] 2008-04-04 Richard Guenther PR middle-end/35823 * fold-const.c (optimize_minmax_comparison): Use the correct type for the constant in the simplified comparison. * gnat.dg/pr35823.adb: New testcase. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@133893 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/ChangeLog | 6 ++++++ gcc/fold-const.c | 3 ++- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gnat.dg/pr35823.adb | 6 ++++++ 4 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/gnat.dg/pr35823.adb diff --git a/gcc/ChangeLog b/gcc/ChangeLog index edda2659b28..8e8c2155ac6 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2008-04-04 Richard Guenther + + PR middle-end/35823 + * fold-const.c (optimize_minmax_comparison): Use the correct + type for the constant in the simplified comparison. + 2008-04-04 Zuxy Meng * config/i386/driver-i386.c (describe_cache): Add l2_sizekb argument. diff --git a/gcc/fold-const.c b/gcc/fold-const.c index 14470c5fd12..ef95ae3d4a5 100644 --- a/gcc/fold-const.c +++ b/gcc/fold-const.c @@ -5547,7 +5547,7 @@ optimize_minmax_comparison (enum tree_code code, tree type, tree op0, tree op1) { tree arg0 = op0; enum tree_code op_code; - tree comp_const = op1; + tree comp_const; tree minmax_const; int consts_equal, consts_lt; tree inner; @@ -5556,6 +5556,7 @@ optimize_minmax_comparison (enum tree_code code, tree type, tree op0, tree op1) op_code = TREE_CODE (arg0); minmax_const = TREE_OPERAND (arg0, 1); + comp_const = fold_convert (TREE_TYPE (arg0), op1); consts_equal = tree_int_cst_equal (minmax_const, comp_const); consts_lt = tree_int_cst_lt (minmax_const, comp_const); inner = TREE_OPERAND (arg0, 0); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index f3b7b6fa265..1812cd2f53e 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2008-04-04 Richard Guenther + + PR middle-end/35823 + * gnat.dg/pr35823.adb: New testcase. + 2008-04-03 Janis Johnson PR c/35712 diff --git a/gcc/testsuite/gnat.dg/pr35823.adb b/gcc/testsuite/gnat.dg/pr35823.adb new file mode 100644 index 00000000000..e882aa3682f --- /dev/null +++ b/gcc/testsuite/gnat.dg/pr35823.adb @@ -0,0 +1,6 @@ +procedure pr35823 (Arg : in String) is + Size : constant Natural := Arg'Size; +begin + null; +end pr35823; + -- 2.11.0