From patchwork Sun Sep 12 00:04:20 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rodrigo Rivas X-Patchwork-Id: 64531 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 03446B6F01 for ; Sun, 12 Sep 2010 10:04:29 +1000 (EST) Received: (qmail 18422 invoked by alias); 12 Sep 2010 00:04:28 -0000 Received: (qmail 18408 invoked by uid 22791); 12 Sep 2010 00:04:27 -0000 X-SWARE-Spam-Status: No, hits=-1.6 required=5.0 tests=AWL, BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, TW_TM X-Spam-Check-By: sourceware.org Received: from mail-wy0-f175.google.com (HELO mail-wy0-f175.google.com) (74.125.82.175) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sun, 12 Sep 2010 00:04:23 +0000 Received: by wye20 with SMTP id 20so4646520wye.20 for ; Sat, 11 Sep 2010 17:04:20 -0700 (PDT) MIME-Version: 1.0 Received: by 10.216.10.145 with SMTP id 17mr2692795wev.27.1284249860866; Sat, 11 Sep 2010 17:04:20 -0700 (PDT) Received: by 10.216.53.137 with HTTP; Sat, 11 Sep 2010 17:04:20 -0700 (PDT) In-Reply-To: <4C8B8595.8070102@redhat.com> References: <4C83BD10.2030901@verizon.net> <4C8512EA.3080903@redhat.com> <20100907125156.GJ1269@tyan-ft48-01.lab.bos.redhat.com> <4C8689C8.706@redhat.com> <4C8A6CB6.8030408@redhat.com> <4C8B8595.8070102@redhat.com> Date: Sun, 12 Sep 2010 02:04:20 +0200 Message-ID: Subject: Re: [C++0x patch] implement range-based for loops From: Rodrigo Rivas To: Jason Merrill Cc: Jakub Jelinek , Ed Smith-Rowland <3dw4rd@verizon.net>, gcc-patches@gcc.gnu.org, Paolo Carlini 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 > OK, makes sense. Here it is. Quite simple, actually. Thank you for your help. Rodrigo. --- Changelog: gcc/cp/ 2010-09-12 Rodrigo Rivas Costa * semantics.c (finish_for_stmt): Always test flag_new_for_scope. (begin_range_for_stmt): Likewise. Index: gcc/cp/semantics.c =================================================================== --- gcc/cp/semantics.c (revision 164212) +++ gcc/cp/semantics.c (working copy) @@ -882,21 +882,13 @@ finish_for_expr (tree expr, tree for_stmt) void finish_for_stmt (tree for_stmt) { - bool scoped; - if (TREE_CODE (for_stmt) == RANGE_FOR_STMT) - { RANGE_FOR_BODY (for_stmt) = do_poplevel (RANGE_FOR_BODY (for_stmt)); - scoped = true; - } else - { FOR_BODY (for_stmt) = do_poplevel (FOR_BODY (for_stmt)); - scoped = flag_new_for_scope > 0; - } /* Pop the scope for the body of the loop. */ - if (scoped) + if (flag_new_for_scope > 0) { tree scope = TREE_CHAIN (for_stmt); TREE_CHAIN (for_stmt) = NULL; @@ -913,11 +905,13 @@ tree begin_range_for_stmt (void) { tree r; + r = build_stmt (input_location, RANGE_FOR_STMT, NULL_TREE, NULL_TREE, NULL_TREE); - /* We can ignore flag_new_for_scope here. */ - TREE_CHAIN (r) = do_pushlevel (sk_for); + if (flag_new_for_scope > 0) + TREE_CHAIN (r) = do_pushlevel (sk_for); + return r; }