Patchwork don't use nreverse for block chains

login
register
mail settings
Submitter Nathan Froyd
Date Aug. 8, 2010, 9:03 p.m.
Message ID <20100808210309.GE4130@codesourcery.com>
Download mbox | patch
Permalink /patch/61235/
State New
Headers show

Comments

Nathan Froyd - Aug. 8, 2010, 9:03 p.m.
We have two separate nreverse functions: one for "generic" tree chains
and one for lists chained with BLOCK_CHAIN.  This patch makes the latter
be used in the Ada front-end, which I think is obvious, and adds asserts
to the generic version to make sure we don't use it when we chould be
using the block version.

Tested on x86_64-unknown-linux-gnu.  OK to commit?

-Nathan

gcc/
	* tree.c (nreverse): Assert that we don't have a BLOCK.

gcc/ada/
	* gcc-interface/utils.c (gnat_poplevel): Use blocks_nreverse.
Mark Mitchell - Aug. 9, 2010, 10:58 a.m.
Nathan Froyd wrote:

> gcc/
> 	* tree.c (nreverse): Assert that we don't have a BLOCK.
> 
> gcc/ada/
> 	* gcc-interface/utils.c (gnat_poplevel): Use blocks_nreverse.

OK.

Patch

diff --git a/gcc/ada/gcc-interface/utils.c b/gcc/ada/gcc-interface/utils.c
index 381d71b..732435b 100644
--- a/gcc/ada/gcc-interface/utils.c
+++ b/gcc/ada/gcc-interface/utils.c
@@ -382,7 +382,7 @@  gnat_poplevel (void)
   tree block = level->block;
 
   BLOCK_VARS (block) = nreverse (BLOCK_VARS (block));
-  BLOCK_SUBBLOCKS (block) = nreverse (BLOCK_SUBBLOCKS (block));
+  BLOCK_SUBBLOCKS (block) = blocks_nreverse (BLOCK_SUBBLOCKS (block));
 
   /* If this is a function-level BLOCK don't do anything.  Otherwise, if there
      are no variables free the block and merge its subblocks into those of its
diff --git a/gcc/tree.c b/gcc/tree.c
index f401145..e67a00c 100644
--- a/gcc/tree.c
+++ b/gcc/tree.c
@@ -2108,6 +2108,9 @@  nreverse (tree t)
   tree prev = 0, decl, next;
   for (decl = t; decl; decl = next)
     {
+      /* We shouldn't be using this function to reverse BLOCK chains; we
+	 have blocks_nreverse for that.  */
+      gcc_checking_assert (TREE_CODE (decl) != BLOCK);
       next = TREE_CHAIN (decl);
       TREE_CHAIN (decl) = prev;
       prev = decl;