diff options
author | Richard Guenther <rguenther@suse.de> | 2007-07-28 16:26:44 +0000 |
---|---|---|
committer | Krister Walfridsson <kristerw@gcc.gnu.org> | 2007-07-28 16:26:44 +0000 |
commit | 539d5e79b5f1a7bf8403391e3a54b50c140b43ef (patch) | |
tree | c6148dda4b174966d7e453ead8ac9abe3a87b666 /gcc | |
parent | 5fcb93f1387118d919887c5f22cfc32b5adfc0ea (diff) | |
download | gcc-539d5e79b5f1a7bf8403391e3a54b50c140b43ef.tar.gz |
re PR middle-end/32920 (error: type mismatch in binary expression)
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.
* gcc.c-torture/compile/pr32920.c: New testcase.
From-SVN: r127021
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/fold-const.c | 16 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 4 | ||||
-rw-r--r-- | gcc/testsuite/gcc.c-torture/compile/pr32920.c | 7 |
4 files changed, 29 insertions, 4 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 13df4ae9ead..47af5547893 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -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, diff --git a/gcc/fold-const.c b/gcc/fold-const.c index 106aa4d3dd5..c7447b925df 100644 --- a/gcc/fold-const.c +++ b/gcc/fold-const.c @@ -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; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 52e0b5e43ed..7c4fd7d0a66 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -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 index 00000000000..c9b627b12dc --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/compile/pr32920.c @@ -0,0 +1,7 @@ +int a; +void +foo(void) +{ + char buf[10]; + a = a < sizeof(buf) ? a : sizeof (buf); +} |