public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* Extend verify_type to check various uses of TYPE_MINVAL
@ 2015-05-03 16:08 Jan Hubicka
  2015-05-04 14:21 ` Rainer Orth
  0 siblings, 1 reply; 5+ messages in thread
From: Jan Hubicka @ 2015-05-03 16:08 UTC (permalink / raw)
  To: gcc-patches

Hi,
this patch extends verify_type to check various uses of TYPE_MINVAL. 
I also added check that MIN_VALUE have compatible type with T:
 useless_type_conversion_p (const_cast <tree> (t), TREE_TYPE (TYPE_MIN_VALUE (t)))
but that one fails interesting ways for C sizetype. I will try to look
into this and thus this patch omits it.

The main motivation is to check that various frontend overrides of TYPE_MINVAL
are under control.

Bootstrapped/regtested x86_64-linux, will commit it as obvious.

Honza

	* tree.c (verify_type): Check various uses of TYPE_MINVAL.
Index: tree.c
===================================================================
--- tree.c	(revision 222723)
+++ tree.c	(working copy)
@@ -12584,15 +12584,60 @@ verify_type (const_tree t)
     }
   else if (t != mv && !verify_type_variant (t, mv))
     error_found = true;
-  /* FIXME: C FE uses TYPE_VFIELD to record C_TYPE_INCOMPLETE_VARS
-     and danagle the pointer from time to time.  */
-  if (RECORD_OR_UNION_TYPE_P (t) && TYPE_VFIELD (t)
-      && TREE_CODE (TYPE_VFIELD (t)) != FIELD_DECL
-      && TREE_CODE (TYPE_VFIELD (t)) != TREE_LIST)
+
+  /* Check various uses of TYPE_MINVAL.  */
+  if (RECORD_OR_UNION_TYPE_P (t))
     {
-      error ("TYPE_VFIELD is not FIELD_DECL nor TREE_LIST");
-      debug_tree (TYPE_VFIELD (t));
+      /* FIXME: C FE uses TYPE_VFIELD to record C_TYPE_INCOMPLETE_VARS
+	 and danagle the pointer from time to time.  */
+      if (TYPE_VFIELD (t)
+	  && TREE_CODE (TYPE_VFIELD (t)) != FIELD_DECL
+	  && TREE_CODE (TYPE_VFIELD (t)) != TREE_LIST)
+	{
+	  error ("TYPE_VFIELD is not FIELD_DECL nor TREE_LIST");
+	  debug_tree (TYPE_VFIELD (t));
+	  error_found = true;
+	}
     }
+  else if (TREE_CODE (t) == POINTER_TYPE)
+    {
+      if (TYPE_NEXT_PTR_TO (t)
+	  && TREE_CODE (TYPE_NEXT_PTR_TO (t)) != POINTER_TYPE)
+	{
+	  error ("TYPE_NEXT_PTR_TO is not POINTER_TYPE");
+	  debug_tree (TYPE_NEXT_PTR_TO (t));
+	  error_found = true;
+	}
+    }
+  else if (TREE_CODE (t) == REFERENCE_TYPE)
+    {
+      if (TYPE_NEXT_REF_TO (t)
+	  && TREE_CODE (TYPE_NEXT_REF_TO (t)) != REFERENCE_TYPE)
+	{
+	  error ("TYPE_NEXT_REF_TO is not REFERENCE_TYPE");
+	  debug_tree (TYPE_NEXT_REF_TO (t));
+	  error_found = true;
+	}
+    }
+  else if (INTEGRAL_TYPE_P (t) || TREE_CODE (t) == REAL_TYPE || TREE_CODE (t) == FIXED_POINT_TYPE)
+    {
+      if (!TYPE_MIN_VALUE (t))
+	;
+      else if (!TREE_CONSTANT (TYPE_MIN_VALUE (t)))
+        {
+	  error ("TYPE_MIN_VALUE is not constant");
+	  debug_tree (TYPE_MIN_VALUE (t));
+	  error_found = true;
+        }
+    }
+  else if (TYPE_MINVAL (t))
+    {
+      error ("TYPE_MINVAL non-NULL");
+      debug_tree (TYPE_MINVAL (t));
+      error_found = true;
+    }
+
+
   if (error_found)
     {
       debug_tree (const_cast <tree> (t));

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

end of thread, other threads:[~2015-05-05  1:48 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-05-03 16:08 Extend verify_type to check various uses of TYPE_MINVAL Jan Hubicka
2015-05-04 14:21 ` Rainer Orth
2015-05-04 14:50   ` Eric Botcazou
2015-05-04 23:50     ` Jan Hubicka
2015-05-05  1:48       ` Jan Hubicka

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