public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* Use expr_location_or in more cases
@ 2011-05-09 19:56 Eric Botcazou
  0 siblings, 0 replies; only message in thread
From: Eric Botcazou @ 2011-05-09 19:56 UTC (permalink / raw)
  To: gcc-patches

[-- Attachment #1: Type: text/plain, Size: 1122 bytes --]

This patch changes fold_ternary_loc to use the new expr_location_or instead of 
the manual equivalent; no functional changes.  Once this is done, grepping the 
file for UNKNOWN_LOCATION yields one occurrence (apart from expr_location_or):

  if ((lhs == 0 || rhs == 0 || operand_equal_p (lhs, rhs, 0))
      && merge_ranges (&in_p, &low, &high, in0_p, low0, high0,
		       in1_p, low1, high1)
      && 0 != (tem = (build_range_check (UNKNOWN_LOCATION, type,
					 lhs != 0 ? lhs
					 : rhs != 0 ? rhs : integer_zero_node,
					 in_p, low, high))))
    {
      if (strict_overflow_p)
	fold_overflow_warning (warnmsg, WARN_STRICT_OVERFLOW_COMPARISON);
      return or_op ? invert_truthvalue_loc (loc, tem) : tem;
    }

It comes from the original loc-ification patch and seems to be an oversight, as 
invert_truthvalue_loc uses LOC just below.  Changed to using LOC as well.

Tested on i586-suse-linux, applied on the mainline as obvious.


2011-05-09  Eric Botcazou  <ebotcazou@adacore.com>

	* fold-const.c (fold_range_test): Pass LOC to build_range_check.
	(fold_ternary_loc): Use expr_location_or.


-- 
Eric Botcazou

[-- Attachment #2: p.diff --]
[-- Type: text/x-diff, Size: 2293 bytes --]

Index: fold-const.c
===================================================================
--- fold-const.c	(revision 173545)
+++ fold-const.c	(working copy)
@@ -4822,7 +4822,7 @@ fold_range_test (location_t loc, enum tr
   if ((lhs == 0 || rhs == 0 || operand_equal_p (lhs, rhs, 0))
       && merge_ranges (&in_p, &low, &high, in0_p, low0, high0,
 		       in1_p, low1, high1)
-      && 0 != (tem = (build_range_check (UNKNOWN_LOCATION, type,
+      && 0 != (tem = (build_range_check (loc, type,
 					 lhs != 0 ? lhs
 					 : rhs != 0 ? rhs : integer_zero_node,
 					 in_p, low, high))))
@@ -13332,9 +13332,7 @@ fold_ternary_loc (location_t loc, enum t
 					     TREE_OPERAND (arg0, 1))
 	  && !HONOR_SIGNED_ZEROS (TYPE_MODE (TREE_TYPE (op2))))
 	{
-	  location_t loc0 = EXPR_LOCATION (arg0);
-	  if (loc0 == UNKNOWN_LOCATION)
-	    loc0 = loc;
+	  location_t loc0 = expr_location_or (arg0, loc);
 	  tem = fold_truth_not_expr (loc0, arg0);
 	  if (tem && COMPARISON_CLASS_P (tem))
 	    {
@@ -13349,9 +13347,7 @@ fold_ternary_loc (location_t loc, enum t
       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;
+	  location_t loc0 = expr_location_or (arg0, loc);
 	  /* See if this can be inverted.  If it can't, possibly because
 	     it was a floating-point inequality comparison, don't do
 	     anything.  */
@@ -13500,9 +13496,7 @@ fold_ternary_loc (location_t loc, enum t
 	  && truth_value_p (TREE_CODE (arg0))
 	  && truth_value_p (TREE_CODE (arg1)))
 	{
-	  location_t loc0 = EXPR_LOCATION (arg0);
-	  if (loc0 == UNKNOWN_LOCATION)
-	    loc0 = loc;
+	  location_t loc0 = expr_location_or (arg0, loc);
 	  /* Only perform transformation if ARG0 is easily inverted.  */
 	  tem = fold_truth_not_expr (loc0, arg0);
 	  if (tem)
@@ -13516,9 +13510,7 @@ fold_ternary_loc (location_t loc, enum t
 	  && truth_value_p (TREE_CODE (arg0))
 	  && truth_value_p (TREE_CODE (op2)))
 	{
-	  location_t loc0 = EXPR_LOCATION (arg0);
-	  if (loc0 == UNKNOWN_LOCATION)
-	    loc0 = loc;
+	  location_t loc0 = expr_location_or (arg0, loc);
 	  /* Only perform transformation if ARG0 is easily inverted.  */
 	  tem = fold_truth_not_expr (loc0, arg0);
 	  if (tem)

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2011-05-09 18:37 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-05-09 19:56 Use expr_location_or in more cases Eric Botcazou

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).