public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r12-18] Remove pedantic_non_lvalue_loc
@ 2021-04-21  8:21 Richard Biener
  0 siblings, 0 replies; only message in thread
From: Richard Biener @ 2021-04-21  8:21 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:8ce9ce6b16b3988f60bb92a916ea50dd3237a532

commit r12-18-g8ce9ce6b16b3988f60bb92a916ea50dd3237a532
Author: Richard Biener <rguenther@suse.de>
Date:   Mon Apr 19 14:38:03 2021 +0200

    Remove pedantic_non_lvalue_loc
    
    This removes pedantic_non_lvalue_loc which doesn't do what it says
    since quite some time in favor of what it actually does and where
    that's not a duplicate (protected_set_expr_location_unshare).
    
    2021-04-19  Richard Biener  <rguenther@suse.de>
    
            * fold-const.c (pedantic_non_lvalue_loc): Remove.
            (fold_binary_loc): Adjust.
            (fold_ternary_loc): Likewise.

Diff:
---
 gcc/fold-const.c | 28 +++++++---------------------
 1 file changed, 7 insertions(+), 21 deletions(-)

diff --git a/gcc/fold-const.c b/gcc/fold-const.c
index 2834278fd76..5a41524702b 100644
--- a/gcc/fold-const.c
+++ b/gcc/fold-const.c
@@ -2619,15 +2619,6 @@ non_lvalue_loc (location_t loc, tree x)
     return x;
   return build1_loc (loc, NON_LVALUE_EXPR, TREE_TYPE (x), x);
 }
-
-/* When pedantic, return an expr equal to X but certainly not valid as a
-   pedantic lvalue.  Otherwise, return X.  */
-
-static tree
-pedantic_non_lvalue_loc (location_t loc, tree x)
-{
-  return protected_set_expr_location_unshare (x, loc);
-}
 \f
 /* Given a tree comparison code, return the code that is the logical inverse.
    It is generally not safe to do this for floating-point comparisons, except
@@ -12532,9 +12523,9 @@ fold_binary_loc (location_t loc, enum tree_code code, tree type,
       if (TREE_SIDE_EFFECTS (arg0) || TREE_CONSTANT (arg1))
 	return NULL_TREE;
       /* Don't let (0, 0) be null pointer constant.  */
-      tem = integer_zerop (arg1) ? build1 (NOP_EXPR, type, arg1)
+      tem = integer_zerop (arg1) ? build1_loc (loc, NOP_EXPR, type, arg1)
 				 : fold_convert_loc (loc, type, arg1);
-      return pedantic_non_lvalue_loc (loc, tem);
+      return tem;
 
     case ASSERT_EXPR:
       /* An ASSERT_EXPR should never be passed to fold_binary.  */
@@ -12781,7 +12772,7 @@ fold_ternary_loc (location_t loc, enum tree_code code, tree type,
                || !contains_label_p (unused_op))
               && (! VOID_TYPE_P (TREE_TYPE (tem))
                   || VOID_TYPE_P (type)))
-	    return pedantic_non_lvalue_loc (loc, tem);
+	    return protected_set_expr_location_unshare (tem, loc);
 	  return NULL_TREE;
 	}
       else if (TREE_CODE (arg0) == VECTOR_CST)
@@ -12864,7 +12855,7 @@ fold_ternary_loc (location_t loc, enum tree_code code, tree type,
 	     a COND, which will recurse.  In that case, the COND_EXPR
 	     is probably the best choice, so leave it alone.  */
 	  && type == TREE_TYPE (arg0))
-	return pedantic_non_lvalue_loc (loc, arg0);
+	return protected_set_expr_location_unshare (arg0, loc);
 
       /* Convert A ? 0 : 1 to !A.  This prefers the use of NOT_EXPR
 	 over COND_EXPR in cases such as floating point comparisons.  */
@@ -12873,10 +12864,8 @@ fold_ternary_loc (location_t loc, enum tree_code code, tree type,
 	  && integer_onep (op2)
 	  && !VECTOR_TYPE_P (type)
 	  && truth_value_p (TREE_CODE (arg0)))
-	return pedantic_non_lvalue_loc (loc,
-				    fold_convert_loc (loc, type,
-					      invert_truthvalue_loc (loc,
-								     arg0)));
+	return fold_convert_loc (loc, type,
+				 invert_truthvalue_loc (loc, arg0));
 
       /* A < 0 ? <sign bit of A> : 0 is simply (A & <sign bit of A>).  */
       if (TREE_CODE (arg0) == LT_EXPR
@@ -12982,10 +12971,7 @@ fold_ternary_loc (location_t loc, enum tree_code code, tree type,
 	     second operand 32-bit -128, which is not a power of two (or vice
 	     versa.  */
 	  && integer_pow2p (TREE_OPERAND (TREE_OPERAND (arg0, 0), 1)))
-	return pedantic_non_lvalue_loc (loc,
-					fold_convert_loc (loc, type,
-							  TREE_OPERAND (arg0,
-									0)));
+	return fold_convert_loc (loc, type, TREE_OPERAND (arg0, 0));
 
       /* Disable the transformations below for vectors, since
 	 fold_binary_op_with_conditional_arg may undo them immediately,


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

only message in thread, other threads:[~2021-04-21  8:21 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-21  8:21 [gcc r12-18] Remove pedantic_non_lvalue_loc Richard Biener

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