public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] TYPE_{MIN,MAX}VAL and TYPE_{MIN,MAX}_VALUE
@ 2017-07-18 13:25 Nathan Sidwell
  2017-07-19 10:25 ` Richard Biener
  0 siblings, 1 reply; 2+ messages in thread
From: Nathan Sidwell @ 2017-07-18 13:25 UTC (permalink / raw)
  To: GCC Patches

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

We currently have both TYPE_{MIN,MAX}VAL and TYPE_{MIN,MAX}_VALUE pairs 
of accessors.  This is confusing.  The former is the tree-agnostic raw 
field accessor, which I propose renaming TYPE_{MIN,MAX}VAL_RAW, as is 
common with other raw accessors.

The latter pair are for accessing numeric types.  I've committed this 
patch where the former pair were used when the latter pair should have 
been.  That's the obvious cleanup.  I'll post renaming patch shortly.

nathan

-- 
Nathan Sidwell

[-- Attachment #2: tv.diff --]
[-- Type: text/x-patch, Size: 5353 bytes --]

2017-07-18  Nathan Sidwell  <nathan@acm.org>

       gcc/
	* tree-parloops.c (try_transform_to_exit_first_loop_alt): Use
	TYPE_MAX_VALUE.

       gcc/c-family/
	* c-warn.c (warn_for_memset): Use TYPE_{MIN,MAX}_VALUE.

       gcc/c/
	* c-parser.c (c_parser_array_notation): Use TYPE_{MIN,MAX}_VALUE.

       gcc/cp/ 
	* cp-array-notation.c (build_array_notation_ref): Use
	TYPE_{MIN,MAX}_VALUE.

       gcc/fortran/
	* trans.c (gfc_build_array_ref): Use TYPE_MAX_VALUE.

Index: c/c-parser.c
===================================================================
--- c/c-parser.c	(revision 250272)
+++ c/c-parser.c	(working copy)
@@ -18238,18 +18238,18 @@ c_parser_array_notation (location_t loc,
 	      return error_mark_node;
 	    }
 
-	  start_index = TYPE_MINVAL (array_type_domain);
+	  start_index = TYPE_MIN_VALUE (array_type_domain);
 	  start_index = fold_build1 (CONVERT_EXPR, ptrdiff_type_node,
 				     start_index);
-	  if (!TYPE_MAXVAL (array_type_domain)
-	      || !TREE_CONSTANT (TYPE_MAXVAL (array_type_domain)))
+	  if (!TYPE_MAX_VALUE (array_type_domain)
+	      || !TREE_CONSTANT (TYPE_MAX_VALUE (array_type_domain)))
 	    {
 	      error_at (loc, "start-index and length fields necessary for "
 			"using array notations in variable-length arrays");
 	      c_parser_skip_until_found (parser, CPP_CLOSE_SQUARE, NULL);
 	      return error_mark_node;
 	    }
-	  end_index = TYPE_MAXVAL (array_type_domain);
+	  end_index = TYPE_MAX_VALUE (array_type_domain);
 	  end_index = fold_build2 (PLUS_EXPR, TREE_TYPE (end_index),
 				   end_index, integer_one_node);
 	  end_index = fold_build1 (CONVERT_EXPR, ptrdiff_type_node, end_index);
Index: c-family/c-warn.c
===================================================================
--- c-family/c-warn.c	(revision 250272)
+++ c-family/c-warn.c	(working copy)
@@ -1799,12 +1799,12 @@ warn_for_memset (location_t loc, tree ar
 	  tree domain = TYPE_DOMAIN (type);
 	  if (!integer_onep (TYPE_SIZE_UNIT (elt_type))
 	      && domain != NULL_TREE
-	      && TYPE_MAXVAL (domain)
-	      && TYPE_MINVAL (domain)
-	      && integer_zerop (TYPE_MINVAL (domain))
+	      && TYPE_MAX_VALUE (domain)
+	      && TYPE_MIN_VALUE (domain)
+	      && integer_zerop (TYPE_MIN_VALUE (domain))
 	      && integer_onep (fold_build2 (MINUS_EXPR, domain,
 					    arg2,
-					    TYPE_MAXVAL (domain))))
+					    TYPE_MAX_VALUE (domain))))
 	    warning_at (loc, OPT_Wmemset_elt_size,
 			"%<memset%> used with length equal to "
 			"number of elements without multiplication "
Index: cp/cp-array-notation.c
===================================================================
--- cp/cp-array-notation.c	(revisio1n 250272)
+++ cp/cp-array-notation.c	(working copy)
@@ -1375,8 +1375,8 @@ build_array_notation_ref (location_t loc
 		    "using array notation with array of unknown bound");
 	  return error_mark_node;
 	}
-      start = cp_fold_convert (ptrdiff_type_node, TYPE_MINVAL (domain));
-      length = size_binop (PLUS_EXPR, TYPE_MAXVAL (domain), size_one_node);
+      start = cp_fold_convert (ptrdiff_type_node, TYPE_MIN_VALUE (domain));
+      length = size_binop (PLUS_EXPR, TYPE_MAX_VALUE (domain), size_one_node);
       length = cp_fold_convert (ptrdiff_type_node, length);
     }
     
Index: fortran/trans.c
===================================================================
--- fortran/trans.c	(revision 250272)
+++ fortran/trans.c	(working copy)
@@ -334,15 +334,15 @@ gfc_build_array_ref (tree base, tree off
   /* Use pointer arithmetic for deferred character length array
      references.  */
   if (type && TREE_CODE (type) == ARRAY_TYPE
-      && TYPE_MAXVAL (TYPE_DOMAIN (type)) != NULL_TREE
-      && (VAR_P (TYPE_MAXVAL (TYPE_DOMAIN (type)))
-	  || TREE_CODE (TYPE_MAXVAL (TYPE_DOMAIN (type))) == INDIRECT_REF)
+      && TYPE_MAX_VALUE (TYPE_DOMAIN (type)) != NULL_TREE
+      && (VAR_P (TYPE_MAX_VALUE (TYPE_DOMAIN (type)))
+	  || TREE_CODE (TYPE_MAX_VALUE (TYPE_DOMAIN (type))) == INDIRECT_REF)
       && decl
-      && (TREE_CODE (TYPE_MAXVAL (TYPE_DOMAIN (type))) == INDIRECT_REF
+      && (TREE_CODE (TYPE_MAX_VALUE (TYPE_DOMAIN (type))) == INDIRECT_REF
 	  || TREE_CODE (decl) == FUNCTION_DECL
-	  || DECL_CONTEXT (TYPE_MAXVAL (TYPE_DOMAIN (type)))
-					== DECL_CONTEXT (decl)))
-    span = TYPE_MAXVAL (TYPE_DOMAIN (type));
+	  || (DECL_CONTEXT (TYPE_MAX_VALUE (TYPE_DOMAIN (type)))
+	      == DECL_CONTEXT (decl))))
+    span = TYPE_MAX_VALUE (TYPE_DOMAIN (type));
   else
     span = NULL_TREE;
 
Index: tree-parloops.c
===================================================================
--- tree-parloops.c	(revision 250272)
+++ tree-parloops.c	(working copy)
@@ -1824,7 +1824,7 @@ try_transform_to_exit_first_loop_alt (st
   /* Figure out whether nit + 1 overflows.  */
   if (TREE_CODE (nit) == INTEGER_CST)
     {
-      if (!tree_int_cst_equal (nit, TYPE_MAXVAL (nit_type)))
+      if (!tree_int_cst_equal (nit, TYPE_MAX_VALUE (nit_type)))
 	{
 	  alt_bound = fold_build2_loc (UNKNOWN_LOCATION, PLUS_EXPR, nit_type,
 				       nit, build_one_cst (nit_type));
@@ -1869,7 +1869,7 @@ try_transform_to_exit_first_loop_alt (st
     return false;
 
   /* Check if nit + 1 overflows.  */
-  widest_int type_max = wi::to_widest (TYPE_MAXVAL (nit_type));
+  widest_int type_max = wi::to_widest (TYPE_MAX_VALUE (nit_type));
   if (nit_max >= type_max)
     return false;
 

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

* Re: [PATCH] TYPE_{MIN,MAX}VAL and TYPE_{MIN,MAX}_VALUE
  2017-07-18 13:25 [PATCH] TYPE_{MIN,MAX}VAL and TYPE_{MIN,MAX}_VALUE Nathan Sidwell
@ 2017-07-19 10:25 ` Richard Biener
  0 siblings, 0 replies; 2+ messages in thread
From: Richard Biener @ 2017-07-19 10:25 UTC (permalink / raw)
  To: Nathan Sidwell; +Cc: GCC Patches

On Tue, Jul 18, 2017 at 3:25 PM, Nathan Sidwell <nathan@acm.org> wrote:
> We currently have both TYPE_{MIN,MAX}VAL and TYPE_{MIN,MAX}_VALUE pairs of
> accessors.  This is confusing.  The former is the tree-agnostic raw field
> accessor, which I propose renaming TYPE_{MIN,MAX}VAL_RAW, as is common with
> other raw accessors.
>
> The latter pair are for accessing numeric types.  I've committed this patch
> where the former pair were used when the latter pair should have been.
> That's the obvious cleanup.  I'll post renaming patch shortly.

Thanks, cleanup looks good.

Richard.

> nathan
>
> --
> Nathan Sidwell

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

end of thread, other threads:[~2017-07-19 10:25 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-07-18 13:25 [PATCH] TYPE_{MIN,MAX}VAL and TYPE_{MIN,MAX}_VALUE Nathan Sidwell
2017-07-19 10:25 ` 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).