diff options
author | rguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4> | 2015-10-29 08:21:50 +0000 |
---|---|---|
committer | rguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4> | 2015-10-29 08:21:50 +0000 |
commit | 6d6ad0cc0fb748f5f9fe5b2d0719e7f90e2dc70a (patch) | |
tree | 988682d93098dc6128f90e4efb0513170f1f9a2e /gcc/fold-const.c | |
parent | a7a322da90f03f24f7a96766858a4a3cd3fe2a4a (diff) | |
download | gcc-6d6ad0cc0fb748f5f9fe5b2d0719e7f90e2dc70a.tar.gz |
2015-10-29 Richard Biener <rguenther@suse.de>
PR middle-end/56956
* fold-const.c (fold_cond_expr_with_comparison): Do not fold
unsigned conditonal negation to ABS_EXPR.
* c-c++-common/ubsan/pr56956.c: New testcase.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@229517 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/fold-const.c')
-rw-r--r-- | gcc/fold-const.c | 6 |
1 files changed, 2 insertions, 4 deletions
diff --git a/gcc/fold-const.c b/gcc/fold-const.c index 71d72f19ece..d88bffc2bc6 100644 --- a/gcc/fold-const.c +++ b/gcc/fold-const.c @@ -4963,8 +4963,7 @@ fold_cond_expr_with_comparison (location_t loc, tree type, case GE_EXPR: case GT_EXPR: if (TYPE_UNSIGNED (TREE_TYPE (arg1))) - arg1 = fold_convert_loc (loc, signed_type_for - (TREE_TYPE (arg1)), arg1); + break; tem = fold_build1_loc (loc, ABS_EXPR, TREE_TYPE (arg1), arg1); return pedantic_non_lvalue_loc (loc, fold_convert_loc (loc, type, tem)); case UNLE_EXPR: @@ -4974,8 +4973,7 @@ fold_cond_expr_with_comparison (location_t loc, tree type, case LE_EXPR: case LT_EXPR: if (TYPE_UNSIGNED (TREE_TYPE (arg1))) - arg1 = fold_convert_loc (loc, signed_type_for - (TREE_TYPE (arg1)), arg1); + break; tem = fold_build1_loc (loc, ABS_EXPR, TREE_TYPE (arg1), arg1); return negate_expr (fold_convert_loc (loc, type, tem)); default: |