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]

Fix type_verifier ICE with non-NULL TREE_PURPOSE in TYPE_ARG_TYPES


Hi,
in my tree I run the type chekcer from dwarf2out and tree streamer and it
reports non-NULL TREE_PURPOSE in TYPE_ARG_TYPES during bootstrap.
This is because C++ FE uses it to store the initial value.

This patch updates verifier to permit this case and free_lang_data_in_type to
clear it.  I am going to commit this as obvious (The checks will trigger often
on LTO builds even in mainline)

I also added documentation. I think dwarf2out may be interested to output this
so one don't need to specify the value from debugger.

Bootstrapped/regtested x86_64-linux

Honza
	* tree.c (free_lang_data_in_type): Free TREE_PURPOSE of
	TYPE_ARG_TYPES list.
	(verify_type): Permit non-NULL TREE_PURPOSE in non-LTO builds.
	* tree.def (FUNCTION_TYPE): Document TREE_PURPOSE in TYPE_ARG_TYPES
Index: tree.c
===================================================================
--- tree.c	(revision 222981)
+++ tree.c	(working copy)
@@ -5041,6 +5041,8 @@ free_lang_data_in_type (tree type)
 	      TREE_VALUE (p) = build_qualified_type (arg_type, quals);
 	      free_lang_data_in_type (TREE_VALUE (p));
 	    }
+	  /* C++ FE uses TREE_PURPOSE to store initial values.  */
+	  TREE_PURPOSE (p) = NULL;
 	}
     }
 
@@ -12817,7 +12831,8 @@ verify_type (const_tree t)
   else if (TREE_CODE (t) == FUNCTION_TYPE || TREE_CODE (t) == METHOD_TYPE)
     for (tree l = TYPE_ARG_TYPES (t); l; l = TREE_CHAIN (l))
       {
-	if (TREE_PURPOSE (l))
+	/* C++ FE uses TREE_PURPOSE to store initial values.  */
+	if (TREE_PURPOSE (l) && in_lto_p)
 	  {
 	    error ("TREE_PURPOSE is non-NULL in TYPE_ARG_TYPES list");
 	    debug_tree (l);
Index: tree.def
===================================================================
--- tree.def	(revision 222981)
+++ tree.def	(working copy)
@@ -245,6 +245,8 @@ DEFTREECODE (POINTER_BOUNDS_TYPE, "point
    TREE_TYPE		    type of value returned.
    TYPE_ARG_TYPES      list of types of arguments expected.
 	this list is made of TREE_LIST nodes.
+	In this list TREE_PURPOSE can be used to indicate the default
+	value of parameter (used by C++ frontend).
    Types of "Procedures" in languages where they are different from functions
    have code FUNCTION_TYPE also, but then TREE_TYPE is zero or void type.  */
 DEFTREECODE (FUNCTION_TYPE, "function_type", tcc_type, 0)


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