From patchwork Sun Aug 8 21:03:09 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nathan Froyd X-Patchwork-Id: 61235 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id 1A742B6EFF for ; Mon, 9 Aug 2010 07:03:17 +1000 (EST) Received: (qmail 14584 invoked by alias); 8 Aug 2010 21:03:15 -0000 Received: (qmail 14571 invoked by uid 22791); 8 Aug 2010 21:03:15 -0000 X-SWARE-Spam-Status: No, hits=-1.7 required=5.0 tests=AWL, BAYES_00, T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mail.codesourcery.com (HELO mail.codesourcery.com) (38.113.113.100) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sun, 08 Aug 2010 21:03:11 +0000 Received: (qmail 8587 invoked from network); 8 Aug 2010 21:03:09 -0000 Received: from unknown (HELO localhost) (froydnj@127.0.0.2) by mail.codesourcery.com with ESMTPA; 8 Aug 2010 21:03:09 -0000 Date: Sun, 8 Aug 2010 14:03:09 -0700 From: Nathan Froyd To: gcc-patches@gcc.gnu.org Subject: [PATCH] don't use nreverse for block chains Message-ID: <20100808210309.GE4130@codesourcery.com> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.17+20080114 (2008-01-14) X-IsSubscribed: yes Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org 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. 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;