public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] gcc/fold-const.c: Correct the report warning position.
       [not found] <55E1AC37.2080002@hotmail.com>
@ 2015-08-29 13:08 ` Chen Gang
  2015-08-31 11:21   ` Richard Biener
  0 siblings, 1 reply; 9+ messages in thread
From: Chen Gang @ 2015-08-29 13:08 UTC (permalink / raw)
  To: law; +Cc: gcc-patches List, Richard Henderson, Iain Buclaw


It is about bug63510: current input_location isn't precise for reporting
warning. The correct location is gimple location of current statement.

ChangeLog:

2015-08-29  Chen Gang  <gang.chen.5i5j@gmail.com>

	* fold-const.c (fold_overflow_warning): Call warning_at instead
	of call warning.
	* tree-ssa-sccvn.c (sccvn_dom_walker::before_dom_children): Call
	fold_binary_loc instead of call fold_binary.
---
 gcc/fold-const.c     | 91 ++++++++++++++++++++++++++++++++--------------------
 gcc/tree-ssa-sccvn.c |  2 +-
 2 files changed, 58 insertions(+), 35 deletions(-)

diff --git a/gcc/fold-const.c b/gcc/fold-const.c
index 1e01726..f22f070 100644
--- a/gcc/fold-const.c
+++ b/gcc/fold-const.c
@@ -299,7 +299,8 @@ fold_deferring_overflow_warnings_p (void)
    overflow is undefined.  */
 
 static void
-fold_overflow_warning (const char* gmsgid, enum warn_strict_overflow_code wc)
+fold_overflow_warning (location_t loc, const char* gmsgid,
+		       enum warn_strict_overflow_code wc)
 {
   if (fold_deferring_overflow_warnings> 0)
     {
@@ -311,7 +312,8 @@ fold_overflow_warning (const char* gmsgid, enum warn_strict_overflow_code wc)
 	}
     }
   else if (issue_strict_overflow_warning (wc))
-    warning (OPT_Wstrict_overflow, gmsgid);
+    warning_at (loc == UNKNOWN_LOCATION ? input_location : loc,
+                OPT_Wstrict_overflow, gmsgid);
 }
 \f
 /* Return true if the built-in mathematical function specified by CODE
@@ -679,7 +681,7 @@ fold_negate_expr (location_t loc, tree t)
 	      if (INTEGRAL_TYPE_P (type)
 		  && (TREE_CODE (tem) != INTEGER_CST
 		      || integer_onep (tem)))
-		fold_overflow_warning (warnmsg, WARN_STRICT_OVERFLOW_MISC);
+		fold_overflow_warning (loc, warnmsg, WARN_STRICT_OVERFLOW_MISC);
 	      return fold_build2_loc (loc, TREE_CODE (t), type,
 				  TREE_OPERAND (t, 0), negate_expr (tem));
 	    }
@@ -5143,7 +5145,7 @@ fold_range_test (location_t loc, enum tree_code code, tree type,
 					 in_p, low, high))))
     {
       if (strict_overflow_p)
-	fold_overflow_warning (warnmsg, WARN_STRICT_OVERFLOW_COMPARISON);
+	fold_overflow_warning (loc, warnmsg, WARN_STRICT_OVERFLOW_COMPARISON);
       return or_op ? invert_truthvalue_loc (loc, tem) : tem;
     }
 
@@ -5177,7 +5179,7 @@ fold_range_test (location_t loc, enum tree_code code, tree type,
 						 low1, high1))))
 	    {
 	      if (strict_overflow_p)
-		fold_overflow_warning (warnmsg,
+		fold_overflow_warning (loc, warnmsg,
 				       WARN_STRICT_OVERFLOW_COMPARISON);
 	      return build2_loc (loc, code == TRUTH_ANDIF_EXPR
 				 ? TRUTH_AND_EXPR : TRUTH_OR_EXPR,
@@ -8177,7 +8179,7 @@ maybe_canonicalize_comparison (location_t loc, enum tree_code code, tree type,
   if (t)
     {
       if (strict_overflow_p)
-	fold_overflow_warning (warnmsg, WARN_STRICT_OVERFLOW_MAGNITUDE);
+	fold_overflow_warning (loc, warnmsg, WARN_STRICT_OVERFLOW_MAGNITUDE);
       return t;
     }
 
@@ -8188,7 +8190,7 @@ maybe_canonicalize_comparison (location_t loc, enum tree_code code, tree type,
   t = maybe_canonicalize_comparison_1 (loc, code, type, arg1, arg0,
 				       &strict_overflow_p);
   if (t && strict_overflow_p)
-    fold_overflow_warning (warnmsg, WARN_STRICT_OVERFLOW_MAGNITUDE);
+    fold_overflow_warning (loc, warnmsg, WARN_STRICT_OVERFLOW_MAGNITUDE);
   return t;
 }
 
@@ -8337,9 +8339,10 @@ fold_comparison (location_t loc, enum tree_code code, tree type,
       else
 	{
 	  if (!equality_code)
-	    fold_overflow_warning ("assuming signed overflow does not occur "
-				   "when changing X +- C1 cmp C2 to "
-				   "X cmp C2 -+ C1",
+	    fold_overflow_warning (loc,
+				   ("assuming signed overflow does not occur "
+				    "when changing X +- C1 cmp C2 to "
+				    "X cmp C2 -+ C1"),
 				   WARN_STRICT_OVERFLOW_COMPARISON);
 	  return fold_build2_loc (loc, code, type, variable, new_const);
 	}
@@ -8452,7 +8455,8 @@ fold_comparison (location_t loc, enum tree_code code, tree type,
 		  && bitpos0 != bitpos1
 		  && (pointer_may_wrap_p (base0, offset0, bitpos0)
 		      || pointer_may_wrap_p (base1, offset1, bitpos1)))
-		fold_overflow_warning (("assuming pointer wraparound does not "
+		fold_overflow_warning (loc,
+				       ("assuming pointer wraparound does not "
 					"occur when comparing P +- C1 with "
 					"P +- C2"),
 				       WARN_STRICT_OVERFLOW_CONDITIONAL);
@@ -8503,7 +8507,8 @@ fold_comparison (location_t loc, enum tree_code code, tree type,
 	      if (!equality_code
 		  && (pointer_may_wrap_p (base0, offset0, bitpos0)
 		      || pointer_may_wrap_p (base1, offset1, bitpos1)))
-		fold_overflow_warning (("assuming pointer wraparound does not "
+		fold_overflow_warning (loc,
+				       ("assuming pointer wraparound does not "
 					"occur when comparing P +- C1 with "
 					"P +- C2"),
 				       WARN_STRICT_OVERFLOW_COMPARISON);
@@ -8561,7 +8566,7 @@ fold_comparison (location_t loc, enum tree_code code, tree type,
 	  && tree_int_cst_compare (const2, cst) == tree_int_cst_sgn (const2)
 	  && tree_int_cst_sgn (cst) == tree_int_cst_sgn (const2))
 	{
-	  fold_overflow_warning (warnmsg, WARN_STRICT_OVERFLOW_COMPARISON);
+	  fold_overflow_warning (loc, warnmsg, WARN_STRICT_OVERFLOW_COMPARISON);
 	  return fold_build2_loc (loc, code, type,
 				  variable1,
 				  fold_build2_loc (loc, TREE_CODE (arg1),
@@ -8576,7 +8581,7 @@ fold_comparison (location_t loc, enum tree_code code, tree type,
 	  && tree_int_cst_compare (const1, cst) == tree_int_cst_sgn (const1)
 	  && tree_int_cst_sgn (cst) == tree_int_cst_sgn (const1))
 	{
-	  fold_overflow_warning (warnmsg, WARN_STRICT_OVERFLOW_COMPARISON);
+	  fold_overflow_warning (loc, warnmsg, WARN_STRICT_OVERFLOW_COMPARISON);
 	  return fold_build2_loc (loc, code, type,
 				  fold_build2_loc (loc, TREE_CODE (arg0),
 						   TREE_TYPE (arg0),
@@ -9019,14 +9024,15 @@ tree_expr_nonzero_warnv_p (tree t, bool *strict_overflow_p)
    Handle warnings about undefined signed overflow.  */
 
 static bool
-tree_expr_nonzero_p (tree t)
+tree_expr_nonzero_p (location_t loc, tree t)
 {
   bool ret, strict_overflow_p;
 
   strict_overflow_p = false;
   ret = tree_expr_nonzero_warnv_p (t, &strict_overflow_p);
   if (strict_overflow_p)
-    fold_overflow_warning (("assuming signed overflow does not occur when "
+    fold_overflow_warning (loc,
+			   ("assuming signed overflow does not occur when "
 			    "determining that expression is always "
 			    "non-zero"),
 			   WARN_STRICT_OVERFLOW_MISC);
@@ -9866,7 +9872,8 @@ fold_binary_loc (location_t loc,
 					     &strict_overflow_p)))
 	    {
 	      if (strict_overflow_p)
-		fold_overflow_warning (("assuming signed overflow does not "
+		fold_overflow_warning (loc,
+				       ("assuming signed overflow does not "
 					"occur when simplifying "
 					"multiplication"),
 				       WARN_STRICT_OVERFLOW_MISC);
@@ -10474,7 +10481,8 @@ fold_binary_loc (location_t loc,
 					 wi::exact_log2 (sval));
 
 	      if (strict_overflow_p)
-		fold_overflow_warning (("assuming signed overflow does not "
+		fold_overflow_warning (loc,
+				       ("assuming signed overflow does not "
 					"occur when simplifying A / (B << N)"),
 				       WARN_STRICT_OVERFLOW_MISC);
 
@@ -10500,7 +10508,8 @@ fold_binary_loc (location_t loc,
 	  && negate_expr_p (arg1))
 	{
 	  if (INTEGRAL_TYPE_P (type))
-	    fold_overflow_warning (("assuming signed overflow does not occur "
+	    fold_overflow_warning (loc,
+				   ("assuming signed overflow does not occur "
 				    "when distributing negation across "
 				    "division"),
 				   WARN_STRICT_OVERFLOW_MISC);
@@ -10515,7 +10524,8 @@ fold_binary_loc (location_t loc,
 	  && negate_expr_p (arg0))
 	{
 	  if (INTEGRAL_TYPE_P (type))
-	    fold_overflow_warning (("assuming signed overflow does not occur "
+	    fold_overflow_warning (loc,
+				   ("assuming signed overflow does not occur "
 				    "when distributing negation across "
 				    "division"),
 				   WARN_STRICT_OVERFLOW_MISC);
@@ -10544,7 +10554,8 @@ fold_binary_loc (location_t loc,
 					 &strict_overflow_p)))
 	{
 	  if (strict_overflow_p)
-	    fold_overflow_warning (("assuming signed overflow does not occur "
+	    fold_overflow_warning (loc,
+				   ("assuming signed overflow does not occur "
 				    "when simplifying division"),
 				   WARN_STRICT_OVERFLOW_MISC);
 	  return fold_convert_loc (loc, type, tem);
@@ -10562,7 +10573,8 @@ fold_binary_loc (location_t loc,
 					 &strict_overflow_p)))
 	{
 	  if (strict_overflow_p)
-	    fold_overflow_warning (("assuming signed overflow does not occur "
+	    fold_overflow_warning (loc,
+				   ("assuming signed overflow does not occur "
 				    "when simplifying modulus"),
 				   WARN_STRICT_OVERFLOW_MISC);
 	  return fold_convert_loc (loc, type, tem);
@@ -11091,7 +11103,7 @@ fold_binary_loc (location_t loc,
 	}
 
       if (integer_zerop (arg1)
-	  && tree_expr_nonzero_p (arg0))
+	  && tree_expr_nonzero_p (loc, arg0))
         {
 	  tree res = constant_boolean_node (code==NE_EXPR, type);
 	  return omit_one_operand_loc (loc, type, res, arg0);
@@ -11291,7 +11303,8 @@ fold_binary_loc (location_t loc,
 	    {
 	      if (TREE_CODE (arg01) == INTEGER_CST
 		  && TYPE_OVERFLOW_UNDEFINED (TREE_TYPE (arg1)))
-		fold_overflow_warning (("assuming signed overflow does not "
+		fold_overflow_warning (loc,
+				       ("assuming signed overflow does not "
 					"occur when assuming that (X - c)> X "
 					"is always false"),
 				       WARN_STRICT_OVERFLOW_ALL);
@@ -11305,7 +11318,8 @@ fold_binary_loc (location_t loc,
 	    {
 	      if (TREE_CODE (arg01) == INTEGER_CST
 		  && TYPE_OVERFLOW_UNDEFINED (TREE_TYPE (arg1)))
-		fold_overflow_warning (("assuming signed overflow does not "
+		fold_overflow_warning (loc,
+				       ("assuming signed overflow does not "
 					"occur when assuming that "
 					"(X + c) < X is always false"),
 				       WARN_STRICT_OVERFLOW_ALL);
@@ -11320,7 +11334,8 @@ fold_binary_loc (location_t loc,
 	    {
 	      if (TREE_CODE (arg01) == INTEGER_CST
 		  && TYPE_OVERFLOW_UNDEFINED (TREE_TYPE (arg1)))
-		fold_overflow_warning (("assuming signed overflow does not "
+		fold_overflow_warning (loc,
+				       ("assuming signed overflow does not "
 					"occur when assuming that "
 					"(X - c) <= X is always true"),
 				       WARN_STRICT_OVERFLOW_ALL);
@@ -11335,7 +11350,8 @@ fold_binary_loc (location_t loc,
 	    {
 	      if (TREE_CODE (arg01) == INTEGER_CST
 		  && TYPE_OVERFLOW_UNDEFINED (TREE_TYPE (arg1)))
-		fold_overflow_warning (("assuming signed overflow does not "
+		fold_overflow_warning (loc,
+				       ("assuming signed overflow does not "
 					"occur when assuming that "
 					"(X + c)>= X is always true"),
 				       WARN_STRICT_OVERFLOW_ALL);
@@ -11350,7 +11366,8 @@ fold_binary_loc (location_t loc,
 		      || (code0 == MINUS_EXPR && is_positive < 0)))
 		{
 		  if (TYPE_OVERFLOW_UNDEFINED (TREE_TYPE (arg1)))
-		    fold_overflow_warning (("assuming signed overflow does "
+		    fold_overflow_warning (loc,
+					   ("assuming signed overflow does "
 					    "not occur when assuming that "
 					    "(X + c)> X is always true"),
 					   WARN_STRICT_OVERFLOW_ALL);
@@ -11362,7 +11379,8 @@ fold_binary_loc (location_t loc,
 		      || (code0 == PLUS_EXPR && is_positive < 0)))
 		{
 		  if (TYPE_OVERFLOW_UNDEFINED (TREE_TYPE (arg1)))
-		    fold_overflow_warning (("assuming signed overflow does "
+		    fold_overflow_warning (loc,
+					   ("assuming signed overflow does "
 					    "not occur when assuming that "
 					    "(X - c) < X is always true"),
 					   WARN_STRICT_OVERFLOW_ALL);
@@ -11375,7 +11393,8 @@ fold_binary_loc (location_t loc,
 		      || (code0 == MINUS_EXPR && is_positive < 0)))
 		{
 		  if (TYPE_OVERFLOW_UNDEFINED (TREE_TYPE (arg1)))
-		    fold_overflow_warning (("assuming signed overflow does "
+		    fold_overflow_warning (loc,
+					   ("assuming signed overflow does "
 					    "not occur when assuming that "
 					    "(X + c) <= X is always false"),
 					   WARN_STRICT_OVERFLOW_ALL);
@@ -11387,7 +11406,8 @@ fold_binary_loc (location_t loc,
 		      || (code0 == PLUS_EXPR && is_positive < 0)))
 		{
 		  if (TYPE_OVERFLOW_UNDEFINED (TREE_TYPE (arg1)))
-		    fold_overflow_warning (("assuming signed overflow does "
+		    fold_overflow_warning (loc,
+					   ("assuming signed overflow does "
 					    "not occur when assuming that "
 					    "(X - c)>= X is always false"),
 					   WARN_STRICT_OVERFLOW_ALL);
@@ -11423,7 +11443,8 @@ fold_binary_loc (location_t loc,
 	  && tree_expr_nonnegative_warnv_p (arg0, &strict_overflow_p))
 	{
 	  if (strict_overflow_p)
-	    fold_overflow_warning (("assuming signed overflow does not occur "
+	    fold_overflow_warning (loc,
+				   ("assuming signed overflow does not occur "
 				    "when simplifying comparison of "
 				    "absolute value and zero"),
 				   WARN_STRICT_OVERFLOW_CONDITIONAL);
@@ -11439,7 +11460,8 @@ fold_binary_loc (location_t loc,
 	  && tree_expr_nonnegative_warnv_p (arg0, &strict_overflow_p))
 	{
 	  if (strict_overflow_p)
-	    fold_overflow_warning (("assuming signed overflow does not occur "
+	    fold_overflow_warning (loc,
+				   ("assuming signed overflow does not occur "
 				    "when simplifying comparison of "
 				    "absolute value and zero"),
 				   WARN_STRICT_OVERFLOW_CONDITIONAL);
@@ -13455,7 +13477,8 @@ tree_expr_nonnegative_p (tree t)
   strict_overflow_p = false;
   ret = tree_expr_nonnegative_warnv_p (t, &strict_overflow_p);
   if (strict_overflow_p)
-    fold_overflow_warning (("assuming signed overflow does not occur when "
+    fold_overflow_warning (input_location,
+			   ("assuming signed overflow does not occur when "
 			    "determining that expression is always "
 			    "non-negative"),
 			   WARN_STRICT_OVERFLOW_MISC);
diff --git a/gcc/tree-ssa-sccvn.c b/gcc/tree-ssa-sccvn.c
index aea6acc..71e5779 100644
--- a/gcc/tree-ssa-sccvn.c
+++ b/gcc/tree-ssa-sccvn.c
@@ -4587,7 +4587,7 @@ sccvn_dom_walker::before_dom_children (basic_block bb)
 	  lhs = vn_get_expr_for (lhs);
 	if (TREE_CODE (rhs) == SSA_NAME)
 	  rhs = vn_get_expr_for (rhs);
-	val = fold_binary (gimple_cond_code (stmt),
+	val = fold_binary_loc (gimple_location (stmt), gimple_cond_code (stmt),
 			   boolean_type_node, lhs, rhs);
 	/* If that didn't simplify to a constant see if we have recorded
 	   temporary expressions from taken edges.  */
-- 
1.9.3

 		 	   		  

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] gcc/fold-const.c: Correct the report warning position.
  2015-08-29 13:08 ` [PATCH] gcc/fold-const.c: Correct the report warning position Chen Gang
@ 2015-08-31 11:21   ` Richard Biener
       [not found]     ` <55E5AB8A.60408@hotmail.com>
  0 siblings, 1 reply; 9+ messages in thread
From: Richard Biener @ 2015-08-31 11:21 UTC (permalink / raw)
  To: Chen Gang; +Cc: law, gcc-patches List, Richard Henderson, Iain Buclaw

On Sat, Aug 29, 2015 at 2:57 PM, Chen Gang <xili_gchen_5257@hotmail.com> wrote:
>
> It is about bug63510: current input_location isn't precise for reporting
> warning. The correct location is gimple location of current statement.

Looks ok to me.  Ok if bootstrapped and tested.

Thanks,
Richard.

> ChangeLog:
>
> 2015-08-29  Chen Gang  <gang.chen.5i5j@gmail.com>
>
>         * fold-const.c (fold_overflow_warning): Call warning_at instead
>         of call warning.
>         * tree-ssa-sccvn.c (sccvn_dom_walker::before_dom_children): Call
>         fold_binary_loc instead of call fold_binary.
> ---
>  gcc/fold-const.c     | 91 ++++++++++++++++++++++++++++++++--------------------
>  gcc/tree-ssa-sccvn.c |  2 +-
>  2 files changed, 58 insertions(+), 35 deletions(-)
>
> diff --git a/gcc/fold-const.c b/gcc/fold-const.c
> index 1e01726..f22f070 100644
> --- a/gcc/fold-const.c
> +++ b/gcc/fold-const.c
> @@ -299,7 +299,8 @@ fold_deferring_overflow_warnings_p (void)
>     overflow is undefined.  */
>
>  static void
> -fold_overflow_warning (const char* gmsgid, enum warn_strict_overflow_code wc)
> +fold_overflow_warning (location_t loc, const char* gmsgid,
> +                      enum warn_strict_overflow_code wc)
>  {
>    if (fold_deferring_overflow_warnings> 0)
>      {
> @@ -311,7 +312,8 @@ fold_overflow_warning (const char* gmsgid, enum warn_strict_overflow_code wc)
>         }
>      }
>    else if (issue_strict_overflow_warning (wc))
> -    warning (OPT_Wstrict_overflow, gmsgid);
> +    warning_at (loc == UNKNOWN_LOCATION ? input_location : loc,
> +                OPT_Wstrict_overflow, gmsgid);
>  }
>
>  /* Return true if the built-in mathematical function specified by CODE
> @@ -679,7 +681,7 @@ fold_negate_expr (location_t loc, tree t)
>               if (INTEGRAL_TYPE_P (type)
>                   && (TREE_CODE (tem) != INTEGER_CST
>                       || integer_onep (tem)))
> -               fold_overflow_warning (warnmsg, WARN_STRICT_OVERFLOW_MISC);
> +               fold_overflow_warning (loc, warnmsg, WARN_STRICT_OVERFLOW_MISC);
>               return fold_build2_loc (loc, TREE_CODE (t), type,
>                                   TREE_OPERAND (t, 0), negate_expr (tem));
>             }
> @@ -5143,7 +5145,7 @@ fold_range_test (location_t loc, enum tree_code code, tree type,
>                                          in_p, low, high))))
>      {
>        if (strict_overflow_p)
> -       fold_overflow_warning (warnmsg, WARN_STRICT_OVERFLOW_COMPARISON);
> +       fold_overflow_warning (loc, warnmsg, WARN_STRICT_OVERFLOW_COMPARISON);
>        return or_op ? invert_truthvalue_loc (loc, tem) : tem;
>      }
>
> @@ -5177,7 +5179,7 @@ fold_range_test (location_t loc, enum tree_code code, tree type,
>                                                  low1, high1))))
>             {
>               if (strict_overflow_p)
> -               fold_overflow_warning (warnmsg,
> +               fold_overflow_warning (loc, warnmsg,
>                                        WARN_STRICT_OVERFLOW_COMPARISON);
>               return build2_loc (loc, code == TRUTH_ANDIF_EXPR
>                                  ? TRUTH_AND_EXPR : TRUTH_OR_EXPR,
> @@ -8177,7 +8179,7 @@ maybe_canonicalize_comparison (location_t loc, enum tree_code code, tree type,
>    if (t)
>      {
>        if (strict_overflow_p)
> -       fold_overflow_warning (warnmsg, WARN_STRICT_OVERFLOW_MAGNITUDE);
> +       fold_overflow_warning (loc, warnmsg, WARN_STRICT_OVERFLOW_MAGNITUDE);
>        return t;
>      }
>
> @@ -8188,7 +8190,7 @@ maybe_canonicalize_comparison (location_t loc, enum tree_code code, tree type,
>    t = maybe_canonicalize_comparison_1 (loc, code, type, arg1, arg0,
>                                        &strict_overflow_p);
>    if (t && strict_overflow_p)
> -    fold_overflow_warning (warnmsg, WARN_STRICT_OVERFLOW_MAGNITUDE);
> +    fold_overflow_warning (loc, warnmsg, WARN_STRICT_OVERFLOW_MAGNITUDE);
>    return t;
>  }
>
> @@ -8337,9 +8339,10 @@ fold_comparison (location_t loc, enum tree_code code, tree type,
>        else
>         {
>           if (!equality_code)
> -           fold_overflow_warning ("assuming signed overflow does not occur "
> -                                  "when changing X +- C1 cmp C2 to "
> -                                  "X cmp C2 -+ C1",
> +           fold_overflow_warning (loc,
> +                                  ("assuming signed overflow does not occur "
> +                                   "when changing X +- C1 cmp C2 to "
> +                                   "X cmp C2 -+ C1"),
>                                    WARN_STRICT_OVERFLOW_COMPARISON);
>           return fold_build2_loc (loc, code, type, variable, new_const);
>         }
> @@ -8452,7 +8455,8 @@ fold_comparison (location_t loc, enum tree_code code, tree type,
>                   && bitpos0 != bitpos1
>                   && (pointer_may_wrap_p (base0, offset0, bitpos0)
>                       || pointer_may_wrap_p (base1, offset1, bitpos1)))
> -               fold_overflow_warning (("assuming pointer wraparound does not "
> +               fold_overflow_warning (loc,
> +                                      ("assuming pointer wraparound does not "
>                                         "occur when comparing P +- C1 with "
>                                         "P +- C2"),
>                                        WARN_STRICT_OVERFLOW_CONDITIONAL);
> @@ -8503,7 +8507,8 @@ fold_comparison (location_t loc, enum tree_code code, tree type,
>               if (!equality_code
>                   && (pointer_may_wrap_p (base0, offset0, bitpos0)
>                       || pointer_may_wrap_p (base1, offset1, bitpos1)))
> -               fold_overflow_warning (("assuming pointer wraparound does not "
> +               fold_overflow_warning (loc,
> +                                      ("assuming pointer wraparound does not "
>                                         "occur when comparing P +- C1 with "
>                                         "P +- C2"),
>                                        WARN_STRICT_OVERFLOW_COMPARISON);
> @@ -8561,7 +8566,7 @@ fold_comparison (location_t loc, enum tree_code code, tree type,
>           && tree_int_cst_compare (const2, cst) == tree_int_cst_sgn (const2)
>           && tree_int_cst_sgn (cst) == tree_int_cst_sgn (const2))
>         {
> -         fold_overflow_warning (warnmsg, WARN_STRICT_OVERFLOW_COMPARISON);
> +         fold_overflow_warning (loc, warnmsg, WARN_STRICT_OVERFLOW_COMPARISON);
>           return fold_build2_loc (loc, code, type,
>                                   variable1,
>                                   fold_build2_loc (loc, TREE_CODE (arg1),
> @@ -8576,7 +8581,7 @@ fold_comparison (location_t loc, enum tree_code code, tree type,
>           && tree_int_cst_compare (const1, cst) == tree_int_cst_sgn (const1)
>           && tree_int_cst_sgn (cst) == tree_int_cst_sgn (const1))
>         {
> -         fold_overflow_warning (warnmsg, WARN_STRICT_OVERFLOW_COMPARISON);
> +         fold_overflow_warning (loc, warnmsg, WARN_STRICT_OVERFLOW_COMPARISON);
>           return fold_build2_loc (loc, code, type,
>                                   fold_build2_loc (loc, TREE_CODE (arg0),
>                                                    TREE_TYPE (arg0),
> @@ -9019,14 +9024,15 @@ tree_expr_nonzero_warnv_p (tree t, bool *strict_overflow_p)
>     Handle warnings about undefined signed overflow.  */
>
>  static bool
> -tree_expr_nonzero_p (tree t)
> +tree_expr_nonzero_p (location_t loc, tree t)
>  {
>    bool ret, strict_overflow_p;
>
>    strict_overflow_p = false;
>    ret = tree_expr_nonzero_warnv_p (t, &strict_overflow_p);
>    if (strict_overflow_p)
> -    fold_overflow_warning (("assuming signed overflow does not occur when "
> +    fold_overflow_warning (loc,
> +                          ("assuming signed overflow does not occur when "
>                             "determining that expression is always "
>                             "non-zero"),
>                            WARN_STRICT_OVERFLOW_MISC);
> @@ -9866,7 +9872,8 @@ fold_binary_loc (location_t loc,
>                                              &strict_overflow_p)))
>             {
>               if (strict_overflow_p)
> -               fold_overflow_warning (("assuming signed overflow does not "
> +               fold_overflow_warning (loc,
> +                                      ("assuming signed overflow does not "
>                                         "occur when simplifying "
>                                         "multiplication"),
>                                        WARN_STRICT_OVERFLOW_MISC);
> @@ -10474,7 +10481,8 @@ fold_binary_loc (location_t loc,
>                                          wi::exact_log2 (sval));
>
>               if (strict_overflow_p)
> -               fold_overflow_warning (("assuming signed overflow does not "
> +               fold_overflow_warning (loc,
> +                                      ("assuming signed overflow does not "
>                                         "occur when simplifying A / (B << N)"),
>                                        WARN_STRICT_OVERFLOW_MISC);
>
> @@ -10500,7 +10508,8 @@ fold_binary_loc (location_t loc,
>           && negate_expr_p (arg1))
>         {
>           if (INTEGRAL_TYPE_P (type))
> -           fold_overflow_warning (("assuming signed overflow does not occur "
> +           fold_overflow_warning (loc,
> +                                  ("assuming signed overflow does not occur "
>                                     "when distributing negation across "
>                                     "division"),
>                                    WARN_STRICT_OVERFLOW_MISC);
> @@ -10515,7 +10524,8 @@ fold_binary_loc (location_t loc,
>           && negate_expr_p (arg0))
>         {
>           if (INTEGRAL_TYPE_P (type))
> -           fold_overflow_warning (("assuming signed overflow does not occur "
> +           fold_overflow_warning (loc,
> +                                  ("assuming signed overflow does not occur "
>                                     "when distributing negation across "
>                                     "division"),
>                                    WARN_STRICT_OVERFLOW_MISC);
> @@ -10544,7 +10554,8 @@ fold_binary_loc (location_t loc,
>                                          &strict_overflow_p)))
>         {
>           if (strict_overflow_p)
> -           fold_overflow_warning (("assuming signed overflow does not occur "
> +           fold_overflow_warning (loc,
> +                                  ("assuming signed overflow does not occur "
>                                     "when simplifying division"),
>                                    WARN_STRICT_OVERFLOW_MISC);
>           return fold_convert_loc (loc, type, tem);
> @@ -10562,7 +10573,8 @@ fold_binary_loc (location_t loc,
>                                          &strict_overflow_p)))
>         {
>           if (strict_overflow_p)
> -           fold_overflow_warning (("assuming signed overflow does not occur "
> +           fold_overflow_warning (loc,
> +                                  ("assuming signed overflow does not occur "
>                                     "when simplifying modulus"),
>                                    WARN_STRICT_OVERFLOW_MISC);
>           return fold_convert_loc (loc, type, tem);
> @@ -11091,7 +11103,7 @@ fold_binary_loc (location_t loc,
>         }
>
>        if (integer_zerop (arg1)
> -         && tree_expr_nonzero_p (arg0))
> +         && tree_expr_nonzero_p (loc, arg0))
>          {
>           tree res = constant_boolean_node (code==NE_EXPR, type);
>           return omit_one_operand_loc (loc, type, res, arg0);
> @@ -11291,7 +11303,8 @@ fold_binary_loc (location_t loc,
>             {
>               if (TREE_CODE (arg01) == INTEGER_CST
>                   && TYPE_OVERFLOW_UNDEFINED (TREE_TYPE (arg1)))
> -               fold_overflow_warning (("assuming signed overflow does not "
> +               fold_overflow_warning (loc,
> +                                      ("assuming signed overflow does not "
>                                         "occur when assuming that (X - c)> X "
>                                         "is always false"),
>                                        WARN_STRICT_OVERFLOW_ALL);
> @@ -11305,7 +11318,8 @@ fold_binary_loc (location_t loc,
>             {
>               if (TREE_CODE (arg01) == INTEGER_CST
>                   && TYPE_OVERFLOW_UNDEFINED (TREE_TYPE (arg1)))
> -               fold_overflow_warning (("assuming signed overflow does not "
> +               fold_overflow_warning (loc,
> +                                      ("assuming signed overflow does not "
>                                         "occur when assuming that "
>                                         "(X + c) < X is always false"),
>                                        WARN_STRICT_OVERFLOW_ALL);
> @@ -11320,7 +11334,8 @@ fold_binary_loc (location_t loc,
>             {
>               if (TREE_CODE (arg01) == INTEGER_CST
>                   && TYPE_OVERFLOW_UNDEFINED (TREE_TYPE (arg1)))
> -               fold_overflow_warning (("assuming signed overflow does not "
> +               fold_overflow_warning (loc,
> +                                      ("assuming signed overflow does not "
>                                         "occur when assuming that "
>                                         "(X - c) <= X is always true"),
>                                        WARN_STRICT_OVERFLOW_ALL);
> @@ -11335,7 +11350,8 @@ fold_binary_loc (location_t loc,
>             {
>               if (TREE_CODE (arg01) == INTEGER_CST
>                   && TYPE_OVERFLOW_UNDEFINED (TREE_TYPE (arg1)))
> -               fold_overflow_warning (("assuming signed overflow does not "
> +               fold_overflow_warning (loc,
> +                                      ("assuming signed overflow does not "
>                                         "occur when assuming that "
>                                         "(X + c)>= X is always true"),
>                                        WARN_STRICT_OVERFLOW_ALL);
> @@ -11350,7 +11366,8 @@ fold_binary_loc (location_t loc,
>                       || (code0 == MINUS_EXPR && is_positive < 0)))
>                 {
>                   if (TYPE_OVERFLOW_UNDEFINED (TREE_TYPE (arg1)))
> -                   fold_overflow_warning (("assuming signed overflow does "
> +                   fold_overflow_warning (loc,
> +                                          ("assuming signed overflow does "
>                                             "not occur when assuming that "
>                                             "(X + c)> X is always true"),
>                                            WARN_STRICT_OVERFLOW_ALL);
> @@ -11362,7 +11379,8 @@ fold_binary_loc (location_t loc,
>                       || (code0 == PLUS_EXPR && is_positive < 0)))
>                 {
>                   if (TYPE_OVERFLOW_UNDEFINED (TREE_TYPE (arg1)))
> -                   fold_overflow_warning (("assuming signed overflow does "
> +                   fold_overflow_warning (loc,
> +                                          ("assuming signed overflow does "
>                                             "not occur when assuming that "
>                                             "(X - c) < X is always true"),
>                                            WARN_STRICT_OVERFLOW_ALL);
> @@ -11375,7 +11393,8 @@ fold_binary_loc (location_t loc,
>                       || (code0 == MINUS_EXPR && is_positive < 0)))
>                 {
>                   if (TYPE_OVERFLOW_UNDEFINED (TREE_TYPE (arg1)))
> -                   fold_overflow_warning (("assuming signed overflow does "
> +                   fold_overflow_warning (loc,
> +                                          ("assuming signed overflow does "
>                                             "not occur when assuming that "
>                                             "(X + c) <= X is always false"),
>                                            WARN_STRICT_OVERFLOW_ALL);
> @@ -11387,7 +11406,8 @@ fold_binary_loc (location_t loc,
>                       || (code0 == PLUS_EXPR && is_positive < 0)))
>                 {
>                   if (TYPE_OVERFLOW_UNDEFINED (TREE_TYPE (arg1)))
> -                   fold_overflow_warning (("assuming signed overflow does "
> +                   fold_overflow_warning (loc,
> +                                          ("assuming signed overflow does "
>                                             "not occur when assuming that "
>                                             "(X - c)>= X is always false"),
>                                            WARN_STRICT_OVERFLOW_ALL);
> @@ -11423,7 +11443,8 @@ fold_binary_loc (location_t loc,
>           && tree_expr_nonnegative_warnv_p (arg0, &strict_overflow_p))
>         {
>           if (strict_overflow_p)
> -           fold_overflow_warning (("assuming signed overflow does not occur "
> +           fold_overflow_warning (loc,
> +                                  ("assuming signed overflow does not occur "
>                                     "when simplifying comparison of "
>                                     "absolute value and zero"),
>                                    WARN_STRICT_OVERFLOW_CONDITIONAL);
> @@ -11439,7 +11460,8 @@ fold_binary_loc (location_t loc,
>           && tree_expr_nonnegative_warnv_p (arg0, &strict_overflow_p))
>         {
>           if (strict_overflow_p)
> -           fold_overflow_warning (("assuming signed overflow does not occur "
> +           fold_overflow_warning (loc,
> +                                  ("assuming signed overflow does not occur "
>                                     "when simplifying comparison of "
>                                     "absolute value and zero"),
>                                    WARN_STRICT_OVERFLOW_CONDITIONAL);
> @@ -13455,7 +13477,8 @@ tree_expr_nonnegative_p (tree t)
>    strict_overflow_p = false;
>    ret = tree_expr_nonnegative_warnv_p (t, &strict_overflow_p);
>    if (strict_overflow_p)
> -    fold_overflow_warning (("assuming signed overflow does not occur when "
> +    fold_overflow_warning (input_location,
> +                          ("assuming signed overflow does not occur when "
>                             "determining that expression is always "
>                             "non-negative"),
>                            WARN_STRICT_OVERFLOW_MISC);
> diff --git a/gcc/tree-ssa-sccvn.c b/gcc/tree-ssa-sccvn.c
> index aea6acc..71e5779 100644
> --- a/gcc/tree-ssa-sccvn.c
> +++ b/gcc/tree-ssa-sccvn.c
> @@ -4587,7 +4587,7 @@ sccvn_dom_walker::before_dom_children (basic_block bb)
>           lhs = vn_get_expr_for (lhs);
>         if (TREE_CODE (rhs) == SSA_NAME)
>           rhs = vn_get_expr_for (rhs);
> -       val = fold_binary (gimple_cond_code (stmt),
> +       val = fold_binary_loc (gimple_location (stmt), gimple_cond_code (stmt),
>                            boolean_type_node, lhs, rhs);
>         /* If that didn't simplify to a constant see if we have recorded
>            temporary expressions from taken edges.  */
> --
> 1.9.3
>
>

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] gcc/fold-const.c: Correct the report warning position.
       [not found]     ` <55E5AB8A.60408@hotmail.com>
@ 2015-09-01 13:42       ` Chen Gang
  2015-10-12 22:34         ` Chen Gang
  0 siblings, 1 reply; 9+ messages in thread
From: Chen Gang @ 2015-09-01 13:42 UTC (permalink / raw)
  To: Richard Biener; +Cc: law, gcc-patches List, Richard Henderson, Iain Buclaw

On 8/31/15 19:12, Richard Biener wrote:
> On Sat, Aug 29, 2015 at 2:57 PM, Chen Gang <xili_gchen_5257@hotmail.com> wrote:
>>
>> It is about bug63510: current input_location isn't precise for reporting
>> warning. The correct location is gimple location of current statement.
>
> Looks ok to me. Ok if bootstrapped and tested.
>

It passes "make check". :-)

Thanks.
--
Chen Gang

Open, share, and attitude like air, water, and life which God blessed
 		 	   		  

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] gcc/fold-const.c: Correct the report warning position.
  2015-09-01 13:42       ` Chen Gang
@ 2015-10-12 22:34         ` Chen Gang
  2015-10-22  2:09           ` Chen Gang
  0 siblings, 1 reply; 9+ messages in thread
From: Chen Gang @ 2015-10-12 22:34 UTC (permalink / raw)
  To: Richard Biener; +Cc: law, gcc-patches List, Richard Henderson, Iain Buclaw

Hello all:

Is this patch OK? If it still needs to do anything, please let me know,
I shall try.

Thanks.

On 9/1/15 21:42, Chen Gang wrote:
> On 8/31/15 19:12, Richard Biener wrote:
>> On Sat, Aug 29, 2015 at 2:57 PM, Chen Gang <xili_gchen_5257@hotmail.com> wrote:
>>>
>>> It is about bug63510: current input_location isn't precise for reporting
>>> warning. The correct location is gimple location of current statement.
>>
>> Looks ok to me. Ok if bootstrapped and tested.
>>
> 
> It passes "make check". :-)
> 
> Thanks.
> --
> Chen Gang
> 
> Open, share, and attitude like air, water, and life which God blessed
>  		 	   		  
> 

-- 
Chen Gang (陈刚)

Open, share, and attitude like air, water, and life which God blessed

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] gcc/fold-const.c: Correct the report warning position.
  2015-10-12 22:34         ` Chen Gang
@ 2015-10-22  2:09           ` Chen Gang
  2015-10-22 19:59             ` Jeff Law
  0 siblings, 1 reply; 9+ messages in thread
From: Chen Gang @ 2015-10-22  2:09 UTC (permalink / raw)
  To: Richard Biener
  Cc: law, gcc-patches List, Richard Henderson, Iain Buclaw, Mike Stump

Hello all:

It is for bug63510, which reported by another members (not me), I guess,
this patch should fix this bug.

Welcome any other members' ideas, suggestions, and completions.

Thanks.

On 10/13/15 06:36, Chen Gang wrote:
> Hello all:
> 
> Is this patch OK? If it still needs to do anything, please let me know,
> I shall try.
> 
> Thanks.
> 
> On 9/1/15 21:42, Chen Gang wrote:
>> On 8/31/15 19:12, Richard Biener wrote:
>>> On Sat, Aug 29, 2015 at 2:57 PM, Chen Gang <xili_gchen_5257@hotmail.com> wrote:
>>>>
>>>> It is about bug63510: current input_location isn't precise for reporting
>>>> warning. The correct location is gimple location of current statement.
>>>
>>> Looks ok to me. Ok if bootstrapped and tested.
>>>
>>
>> It passes "make check". :-)
>>

Thanks.
-- 
Chen Gang (陈刚)

Open, share, and attitude like air, water, and life which God blessed

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] gcc/fold-const.c: Correct the report warning position.
  2015-10-22  2:09           ` Chen Gang
@ 2015-10-22 19:59             ` Jeff Law
  2015-10-23  9:06               ` Richard Biener
  0 siblings, 1 reply; 9+ messages in thread
From: Jeff Law @ 2015-10-22 19:59 UTC (permalink / raw)
  To: Chen Gang, Richard Biener
  Cc: gcc-patches List, Richard Henderson, Iain Buclaw, Mike Stump

On 10/21/2015 04:31 PM, Chen Gang wrote:
> Hello all:
>
> It is for bug63510, which reported by another members (not me), I guess,
> this patch should fix this bug.
>
> Welcome any other members' ideas, suggestions, and completions.
Note that the call to fold_binary from tree-ssa-sccvn.c has been 
removed.  So that hunk either needs to be removed or the change applied 
elsewhere.

I think passing around the location through fold-const.c is OK.

I'd like to see a testcase in a form ready for inclusion into the testsuite.

jeff

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] gcc/fold-const.c: Correct the report warning position.
  2015-10-22 19:59             ` Jeff Law
@ 2015-10-23  9:06               ` Richard Biener
  2015-10-24  2:32                 ` Chen Gang
  0 siblings, 1 reply; 9+ messages in thread
From: Richard Biener @ 2015-10-23  9:06 UTC (permalink / raw)
  To: Jeff Law
  Cc: Chen Gang, gcc-patches List, Richard Henderson, Iain Buclaw, Mike Stump

On Thu, Oct 22, 2015 at 9:46 PM, Jeff Law <law@redhat.com> wrote:
> On 10/21/2015 04:31 PM, Chen Gang wrote:
>>
>> Hello all:
>>
>> It is for bug63510, which reported by another members (not me), I guess,
>> this patch should fix this bug.
>>
>> Welcome any other members' ideas, suggestions, and completions.
>
> Note that the call to fold_binary from tree-ssa-sccvn.c has been removed.
> So that hunk either needs to be removed or the change applied elsewhere.
>
> I think passing around the location through fold-const.c is OK.
>
> I'd like to see a testcase in a form ready for inclusion into the testsuite.

As an additional remark - I'd like to see us not use input_location
but always loc,
even if UNKNOWN_LOCATION.  The diagnostic machinery should handle this
correctly(?).  That is, if bootstrap/testign doesn't show testsuite
regressions because
of this.

Richard.

> jeff
>

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] gcc/fold-const.c: Correct the report warning position.
  2015-10-23  9:06               ` Richard Biener
@ 2015-10-24  2:32                 ` Chen Gang
  2015-10-24 17:31                   ` Chen Gang
  0 siblings, 1 reply; 9+ messages in thread
From: Chen Gang @ 2015-10-24  2:32 UTC (permalink / raw)
  To: Richard Biener, Jeff Law
  Cc: gcc-patches List, Richard Henderson, Iain Buclaw, Mike Stump


On 10/23/15 16:56, Richard Biener wrote:
> On Thu, Oct 22, 2015 at 9:46 PM, Jeff Law <law@redhat.com> wrote:
>>
>> Note that the call to fold_binary from tree-ssa-sccvn.c has been removed.
>> So that hunk either needs to be removed or the change applied elsewhere.
>>

Oh, really, it uses gimple_simplify instead of.

>> I think passing around the location through fold-const.c is OK.
>>

OK, thanks.

>> I'd like to see a testcase in a form ready for inclusion into the testsuite.

OK, thanks, I shall try.

> 
> As an additional remark - I'd like to see us not use input_location
> but always loc,

For me, it sounds reasonable.

> even if UNKNOWN_LOCATION.  The diagnostic machinery should handle this
> correctly(?).  That is, if bootstrap/testign doesn't show testsuite
> regressions because
> of this.
> 

I will try.


Hope I can finish trying above all within 2 days (2015-10-25).


Thanks.
-- 
Chen Gang (陈刚)

Open, share, and attitude like air, water, and life which God blessed

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] gcc/fold-const.c: Correct the report warning position.
  2015-10-24  2:32                 ` Chen Gang
@ 2015-10-24 17:31                   ` Chen Gang
  0 siblings, 0 replies; 9+ messages in thread
From: Chen Gang @ 2015-10-24 17:31 UTC (permalink / raw)
  To: Richard Biener, Jeff Law
  Cc: gcc-patches List, Richard Henderson, Iain Buclaw, Mike Stump

Hello all:

After have a test, "gcc version 6.0.0 20151023 (experimental) (GCC)" has
no this issue. And bug63510 can be closed. :-)

So for me, we need not spend additional time resources on it. I shall
continue to other issues in gcc or qemu. Now, I guess, my 1st priority
is to rewrite tilegx qemu floating point insns within 2015-10-31.

Welcome additional ideas, suggestions, and completions.

Thanks.

On 10/24/15 08:15, Chen Gang wrote:
> 
> On 10/23/15 16:56, Richard Biener wrote:
>> On Thu, Oct 22, 2015 at 9:46 PM, Jeff Law <law@redhat.com> wrote:
>>>
>>> Note that the call to fold_binary from tree-ssa-sccvn.c has been removed.
>>> So that hunk either needs to be removed or the change applied elsewhere.
>>>
> 
> Oh, really, it uses gimple_simplify instead of.
> 
>>> I think passing around the location through fold-const.c is OK.
>>>
> 
> OK, thanks.
> 
>>> I'd like to see a testcase in a form ready for inclusion into the testsuite.
> 
> OK, thanks, I shall try.
> 
>>
>> As an additional remark - I'd like to see us not use input_location
>> but always loc,
> 
> For me, it sounds reasonable.
> 
>> even if UNKNOWN_LOCATION.  The diagnostic machinery should handle this
>> correctly(?).  That is, if bootstrap/testign doesn't show testsuite
>> regressions because
>> of this.
>>
> 
> I will try.
> 
> 
> Hope I can finish trying above all within 2 days (2015-10-25).
> 
> 
> Thanks.
> 

-- 
Chen Gang (陈刚)

Open, share, and attitude like air, water, and life which God blessed

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2015-10-24 16:31 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <55E1AC37.2080002@hotmail.com>
2015-08-29 13:08 ` [PATCH] gcc/fold-const.c: Correct the report warning position Chen Gang
2015-08-31 11:21   ` Richard Biener
     [not found]     ` <55E5AB8A.60408@hotmail.com>
2015-09-01 13:42       ` Chen Gang
2015-10-12 22:34         ` Chen Gang
2015-10-22  2:09           ` Chen Gang
2015-10-22 19:59             ` Jeff Law
2015-10-23  9:06               ` Richard Biener
2015-10-24  2:32                 ` Chen Gang
2015-10-24 17:31                   ` Chen Gang

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).