]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
2007-07-28 Richard Guenther <rguenther@suse.de>
authorkristerw <kristerw@138bc75d-0d04-0410-961f-82ee72b054a4>
Sat, 28 Jul 2007 16:26:44 +0000 (16:26 +0000)
committerkristerw <kristerw@138bc75d-0d04-0410-961f-82ee72b054a4>
Sat, 28 Jul 2007 16:26:44 +0000 (16:26 +0000)
PR middle-end/32920
* fold-const.c (fold_cond_expr_with_comparison): Convert
operand zero of MIN/MAX_EXPR to correct type.

* gcc.c-torture/compile/pr32920.c: New testcase.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@127021 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/fold-const.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.c-torture/compile/pr32920.c [new file with mode: 0644]

index 13df4ae9ead43582fce1240ec695881b307c24e4..47af5547893eea26180a4e5fce496f1de1b9e808 100644 (file)
@@ -1,3 +1,9 @@
+2007-07-28  Richard Guenther  <rguenther@suse.de>
+
+       PR middle-end/32920
+       * fold-const.c (fold_cond_expr_with_comparison): Convert
+       operand zero of MIN/MAX_EXPR to correct type.
+
 2007-07-28  Kaveh R. Ghazi  <ghazi@caip.rutgers.edu>
 
        * calls.c (special_function_p, setjmp_call_p, alloca_call_p,
index 106aa4d3dd5e8d56311b3552ba5c46f6640746b6..c7447b925df8b4301375ab5073d89792bf3b7afd 100644 (file)
@@ -4958,7 +4958,9 @@ fold_cond_expr_with_comparison (tree type, tree arg0, tree arg1, tree arg2)
                                             build_int_cst (type, 1), 0),
                                OEP_ONLY_CONST))
          return pedantic_non_lvalue (fold_build2 (MIN_EXPR,
-                                                  type, arg1, arg2));
+                                                  type,
+                                                  fold_convert (type, arg1),
+                                                  arg2));
        break;
 
       case LE_EXPR:
@@ -4970,7 +4972,9 @@ fold_cond_expr_with_comparison (tree type, tree arg0, tree arg1, tree arg2)
                                             build_int_cst (type, 1), 0),
                                OEP_ONLY_CONST))
          return pedantic_non_lvalue (fold_build2 (MIN_EXPR,
-                                                  type, arg1, arg2));
+                                                  type,
+                                                  fold_convert (type, arg1),
+                                                  arg2));
        break;
 
       case GT_EXPR:
@@ -4982,7 +4986,9 @@ fold_cond_expr_with_comparison (tree type, tree arg0, tree arg1, tree arg2)
                                             build_int_cst (type, 1), 0),
                                OEP_ONLY_CONST))
          return pedantic_non_lvalue (fold_build2 (MAX_EXPR,
-                                                  type, arg1, arg2));
+                                                  type,
+                                                  fold_convert (type, arg1),
+                                                  arg2));
        break;
 
       case GE_EXPR:
@@ -4994,7 +5000,9 @@ fold_cond_expr_with_comparison (tree type, tree arg0, tree arg1, tree arg2)
                                             build_int_cst (type, 1), 0),
                                OEP_ONLY_CONST))
          return pedantic_non_lvalue (fold_build2 (MAX_EXPR,
-                                                  type, arg1, arg2));
+                                                  type,
+                                                  fold_convert (type, arg1),
+                                                  arg2));
        break;
       case NE_EXPR:
        break;
index 52e0b5e43ed356f85b5eb492b077ce0fffcc1ab1..7c4fd7d0a66317faf2ea7d9fe437857acb32d636 100644 (file)
@@ -1,3 +1,7 @@
+2007-07-28  Richard Guenther  <rguenther@suse.de>
+
+       * gcc.c-torture/compile/pr32920.c: New testcase.
+
 2007-07-28  Simon Martin  <simartin@users.sourceforge.net>
 
        PR c++/30917
diff --git a/gcc/testsuite/gcc.c-torture/compile/pr32920.c b/gcc/testsuite/gcc.c-torture/compile/pr32920.c
new file mode 100644 (file)
index 0000000..c9b627b
--- /dev/null
@@ -0,0 +1,7 @@
+int a;
+void
+foo(void)
+{
+  char buf[10];
+  a = a < sizeof(buf) ? a : sizeof (buf);
+}