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]

[lto] Stop using void_list_node in equality comparisons.


Hi,

Attached is a patch to stop using void_list_node in equality
comparisions.

The current API for constructing TYPE_ARG_TYPES includes
alloc_parm_types and nth_parm_type_ptr.  Neither of these functions
guarantees that

  tree_last (TYPE_ARG_TYPES (...)) == void_list_node

if and only if

  TREE_VALUE (tree_last (TYPE_ARG_TYPES (...))) == void_type_node

However, certain functions expect that the last TREE_LIST node is
void_list_node.

This patch changes those functions to expect void_type_node in
TREE_VALUE of the last TREE_LIST node.  This way, it is OK for one of
my conversion patches to introduce TYPE_ARG_TYPES that ends with a
TREE_LIST node (!= void_list_node) whose TREE_VALUE is still
void_type_node.

Tested on x86_64-pc-linux-gnu.  Committed to the LTO branch as
obvious.

Kazu Hirata

2006-08-05  Kazu Hirata  <kazu@codesourcery.com>

	* decl2.c (coerce_new_type, coerce_delete_type): Don't use
	void_list_node in equality comparisons.
	* pt.c (tsubst, tsubst_copy, tsubst_copy_asm_operands,
	tsubst_copy_and_build): Likewise.
	* typeck.c (commonparms): Likewise.

Index: cp/decl2.c
===================================================================
--- cp/decl2.c	(revision 115923)
+++ cp/decl2.c	(working copy)
@@ -1154,11 +1154,15 @@ coerce_new_type (tree type)
       error ("%<operator new%> must return type %qT", ptr_type_node);
     }
 
-  if (!args || args == void_list_node
+  if (!args
+      || (TREE_VALUE (args) == void_type_node
+	  && TREE_CHAIN (args) == NULL_TREE)
       || !same_type_p (TREE_VALUE (args), size_type_node))
     {
       e = 2;
-      if (args && args != void_list_node)
+      if (args
+	  && (TREE_VALUE (args) != void_type_node
+	      || TREE_CHAIN (args) != NULL_TREE))
 	args = TREE_CHAIN (args);
       pedwarn ("%<operator new%> takes type %<size_t%> (%qT) "
 	       "as first parameter", size_type_node);
@@ -1192,11 +1196,16 @@ coerce_delete_type (tree type)
       error ("%<operator delete%> must return type %qT", void_type_node);
     }
 
-  if (!args || args == void_list_node
+  if (!args
+      || (args
+	  && TREE_VALUE (args) == void_type_node
+	  && TREE_CHAIN (args) == NULL_TREE)
       || !same_type_p (TREE_VALUE (args), ptr_type_node))
     {
       e = 2;
-      if (args && args != void_list_node)
+      if (args
+	  && (TREE_VALUE (args) != void_type_node
+	      || TREE_CHAIN (args) != NULL_TREE))
 	args = TREE_CHAIN (args);
       error ("%<operator delete%> takes type %qT as first parameter",
 	     ptr_type_node);
Index: cp/pt.c
===================================================================
--- cp/pt.c	(revision 115923)
+++ cp/pt.c	(working copy)
@@ -7112,7 +7112,9 @@ tsubst (tree t, tree args, tsubst_flags_
       {
 	tree purpose, value, chain;
 
-	if (t == void_list_node)
+	if (t
+	    && TREE_VALUE (t) == void_type_node
+	    && TREE_CHAIN (t) == NULL_TREE)
 	  return t;
 
 	purpose = TREE_PURPOSE (t);
@@ -7942,7 +7944,9 @@ tsubst_copy (tree t, tree args, tsubst_f
       {
 	tree purpose, value, chain;
 
-	if (t == void_list_node)
+	if (t
+	    && TREE_VALUE (t) == void_type_node
+	    && TREE_CHAIN (t) == NULL_TREE)
 	  return t;
 
 	purpose = TREE_PURPOSE (t);
@@ -8072,8 +8076,10 @@ tsubst_copy_asm_operands (tree t, tree a
     return tsubst_copy_and_build (t, args, complain, in_decl,
 				  /*function_p=*/false);
 
-  if (t == void_list_node)
-    return t;
+  if (t
+      && TREE_VALUE (t) == void_type_node
+      && TREE_CHAIN (t) == NULL_TREE)
+     return t;
 
   purpose = TREE_PURPOSE (t);
   if (purpose)
@@ -8856,7 +8862,9 @@ tsubst_copy_and_build (tree t,
       {
 	tree purpose, value, chain;
 
-	if (t == void_list_node)
+	if (t
+	    && TREE_VALUE (t) == void_type_node
+	    && TREE_CHAIN (t) == NULL_TREE)
 	  return t;
 
 	purpose = TREE_PURPOSE (t);
Index: cp/typeck.c
===================================================================
--- cp/typeck.c	(revision 115923)
+++ cp/typeck.c	(working copy)
@@ -174,7 +174,9 @@ commonparms (tree p1, tree p2)
   len = list_length (p1);
   newargs = tree_last (p1);
 
-  if (newargs == void_list_node)
+  if (newargs
+      && TREE_VALUE (newargs) == void_type_node
+      && TREE_CHAIN (newargs) == NULL_TREE)
     i = 1;
   else
     {


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