This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Extend verify_type to check various uses of TYPE_MINVAL


Hi,
if my wifi connectoin allows, I will commit the following patch I tested in
meantime.  It also adds sanity checking for TYPE_MAXVAL that does not seem to
trigger any issues anymore.

>From type_non_common it remains to check values and binfo. I hope to kill all
those fields and move them to derived structures where they belong but it is
harder than it seems because way obj-c++ shares datastructures with C++ and C
FEs and abuse these fields in interesting ways. (I got stuck on these last
stage1)

Honza

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 222791)
+++ ChangeLog	(working copy)
@@ -1,3 +1,9 @@
+2015-05-02  Jan Hubicka  <hubicka@ucw.cz>
+
+	* tree.c (verify_type): Check various uses of TYPE_MAXVAL;
+	fix overactive TYPE_MIN_VALUE check and add FIXME for type
+	compatibility problems.
+
 2015-05-04  Ajit Agarwal  <ajitkum@xilinx.com>
 
 	* config/microblaze/microblaze.md (cbranchsi4): Added immediate
Index: tree.c
===================================================================
--- tree.c	(revision 222753)
+++ tree.c	(working copy)
@@ -12621,14 +12621,9 @@ verify_type (const_tree t)
     }
   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;
-        }
+      /* FIXME: The following check should pass:
+	  useless_type_conversion_p (const_cast <tree> (t), TREE_TYPE (TYPE_MIN_VALUE (t))
+	 bud does not for C sizetypes in LTO.  */
     }
   else if (TYPE_MINVAL (t))
     {
@@ -12637,6 +12632,62 @@ verify_type (const_tree t)
       error_found = true;
     }
 
+  /* Check various uses of TYPE_MAXVAL.  */
+  if (RECORD_OR_UNION_TYPE_P (t))
+    {
+      if (TYPE_METHODS (t) && TREE_CODE (TYPE_METHODS (t)) != FUNCTION_DECL
+	  && TREE_CODE (TYPE_METHODS (t)) != TEMPLATE_DECL)
+	{
+	  error ("TYPE_METHODS is not FUNCTION_DECL nor TEMPLATE_DECL");
+	  debug_tree (TYPE_METHODS (t));
+	  error_found = true;
+	}
+    }
+  else if (TREE_CODE (t) == FUNCTION_TYPE || TREE_CODE (t) == METHOD_TYPE)
+    {
+      if (TYPE_METHOD_BASETYPE (t)
+	  && TREE_CODE (TYPE_METHOD_BASETYPE (t)) != RECORD_TYPE
+	  && TREE_CODE (TYPE_METHOD_BASETYPE (t)) != UNION_TYPE)
+	{
+	  error ("TYPE_METHOD_BASETYPE is not record nor union");
+	  debug_tree (TYPE_METHOD_BASETYPE (t));
+	  error_found = true;
+	}
+    }
+  else if (TREE_CODE (t) == OFFSET_TYPE)
+    {
+      if (TYPE_OFFSET_BASETYPE (t)
+	  && TREE_CODE (TYPE_OFFSET_BASETYPE (t)) != RECORD_TYPE
+	  && TREE_CODE (TYPE_OFFSET_BASETYPE (t)) != UNION_TYPE)
+	{
+	  error ("TYPE_OFFSET_BASETYPE is not record nor union");
+	  debug_tree (TYPE_OFFSET_BASETYPE (t));
+	  error_found = true;
+	}
+    }
+  else if (INTEGRAL_TYPE_P (t) || TREE_CODE (t) == REAL_TYPE || TREE_CODE (t) == FIXED_POINT_TYPE)
+    {
+      /* FIXME: The following check should pass:
+	  useless_type_conversion_p (const_cast <tree> (t), TREE_TYPE (TYPE_MAX_VALUE (t))
+	 bud does not for C sizetypes in LTO.  */
+    }
+  else if (TREE_CODE (t) == ARRAY_TYPE)
+    {
+      if (TYPE_ARRAY_MAX_SIZE (t)
+	  && TREE_CODE (TYPE_ARRAY_MAX_SIZE (t)) != INTEGER_CST)
+        {
+	  error ("TYPE_ARRAY_MAX_SIZE not INTEGER_CST");
+	  debug_tree (TYPE_ARRAY_MAX_SIZE (t));
+	  error_found = true;
+        } 
+    }
+  else if (TYPE_MAXVAL (t))
+    {
+      error ("TYPE_MAXVAL non-NULL");
+      debug_tree (TYPE_MAXVAL (t));
+      error_found = true;
+    }
+
 
   if (error_found)
     {


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]