aboutsummaryrefslogtreecommitdiff
path: root/gcc/fold-const.c
diff options
context:
space:
mode:
authorEric Botcazou <ebotcazou@adacore.com>2011-03-24 16:15:22 +0000
committerEric Botcazou <ebotcazou@gcc.gnu.org>2011-03-24 16:15:22 +0000
commitfe784e0dd88303485bcbe0c3f211fd1a61c58ef8 (patch)
tree18d2c0f369112d771f572e44ac8bc4f35041a55c /gcc/fold-const.c
parente3c4580e400367dfceec3e4c0539b43fcb4ed340 (diff)
downloadgcc-fe784e0dd88303485bcbe0c3f211fd1a61c58ef8.zip
gcc-fe784e0dd88303485bcbe0c3f211fd1a61c58ef8.tar.gz
gcc-fe784e0dd88303485bcbe0c3f211fd1a61c58ef8.tar.bz2
fold-const.c (fold_ternary_loc): Preserve the location (if any) of the argument in calls to fold_truth_not_expr.
* fold-const.c (fold_ternary_loc): Preserve the location (if any) of the argument in calls to fold_truth_not_expr. From-SVN: r171403
Diffstat (limited to 'gcc/fold-const.c')
-rw-r--r--gcc/fold-const.c20
1 files changed, 16 insertions, 4 deletions
diff --git a/gcc/fold-const.c b/gcc/fold-const.c
index 9baa9eb..32b7a27 100644
--- a/gcc/fold-const.c
+++ b/gcc/fold-const.c
@@ -13327,7 +13327,10 @@ fold_ternary_loc (location_t loc, enum tree_code code, tree type,
TREE_OPERAND (arg0, 1))
&& !HONOR_SIGNED_ZEROS (TYPE_MODE (TREE_TYPE (op2))))
{
- tem = fold_truth_not_expr (loc, arg0);
+ location_t loc0 = EXPR_LOCATION (arg0);
+ if (loc0 == UNKNOWN_LOCATION)
+ loc0 = loc;
+ tem = fold_truth_not_expr (loc0, arg0);
if (tem && COMPARISON_CLASS_P (tem))
{
tem = fold_cond_expr_with_comparison (loc, type, tem, op2, op1);
@@ -13341,10 +13344,13 @@ fold_ternary_loc (location_t loc, enum tree_code code, tree type,
if (truth_value_p (TREE_CODE (arg0))
&& tree_swap_operands_p (op1, op2, false))
{
+ location_t loc0 = EXPR_LOCATION (arg0);
+ if (loc0 == UNKNOWN_LOCATION)
+ loc0 = loc;
/* See if this can be inverted. If it can't, possibly because
it was a floating-point inequality comparison, don't do
anything. */
- tem = fold_truth_not_expr (loc, arg0);
+ tem = fold_truth_not_expr (loc0, arg0);
if (tem)
return fold_build3_loc (loc, code, type, tem, op2, op1);
}
@@ -13489,8 +13495,11 @@ fold_ternary_loc (location_t loc, enum tree_code code, tree type,
&& truth_value_p (TREE_CODE (arg0))
&& truth_value_p (TREE_CODE (arg1)))
{
+ location_t loc0 = EXPR_LOCATION (arg0);
+ if (loc0 == UNKNOWN_LOCATION)
+ loc0 = loc;
/* Only perform transformation if ARG0 is easily inverted. */
- tem = fold_truth_not_expr (loc, arg0);
+ tem = fold_truth_not_expr (loc0, arg0);
if (tem)
return fold_build2_loc (loc, TRUTH_ORIF_EXPR, type,
fold_convert_loc (loc, type, tem),
@@ -13502,8 +13511,11 @@ fold_ternary_loc (location_t loc, enum tree_code code, tree type,
&& truth_value_p (TREE_CODE (arg0))
&& truth_value_p (TREE_CODE (op2)))
{
+ location_t loc0 = EXPR_LOCATION (arg0);
+ if (loc0 == UNKNOWN_LOCATION)
+ loc0 = loc;
/* Only perform transformation if ARG0 is easily inverted. */
- tem = fold_truth_not_expr (loc, arg0);
+ tem = fold_truth_not_expr (loc0, arg0);
if (tem)
return fold_build2_loc (loc, TRUTH_ANDIF_EXPR, type,
fold_convert_loc (loc, type, tem),