From patchwork Thu Jan 13 11:49:11 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rodrigo Rivas X-Patchwork-Id: 78726 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 65A4AB6EF1 for ; Thu, 13 Jan 2011 22:49:22 +1100 (EST) Received: (qmail 22294 invoked by alias); 13 Jan 2011 11:49:19 -0000 Received: (qmail 22284 invoked by uid 22791); 13 Jan 2011 11:49:18 -0000 X-SWARE-Spam-Status: No, hits=-2.2 required=5.0 tests=AWL, BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, RFC_ABUSE_POST X-Spam-Check-By: sourceware.org Received: from mail-ww0-f51.google.com (HELO mail-ww0-f51.google.com) (74.125.82.51) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 13 Jan 2011 11:49:14 +0000 Received: by wwe15 with SMTP id 15so1554522wwe.8 for ; Thu, 13 Jan 2011 03:49:12 -0800 (PST) MIME-Version: 1.0 Received: by 10.216.48.5 with SMTP id u5mr1769306web.96.1294919351878; Thu, 13 Jan 2011 03:49:11 -0800 (PST) Received: by 10.216.235.33 with HTTP; Thu, 13 Jan 2011 03:49:11 -0800 (PST) In-Reply-To: <4D2EE2E0.3030705@gnu.org> References: <4CE14363.2020001@redhat.com> <4CEC22E2.4010402@redhat.com> <4CEFDE42.1020005@redhat.com> <4D2EC02D.6010400@gnu.org> <4D2EE2E0.3030705@gnu.org> Date: Thu, 13 Jan 2011 12:49:11 +0100 Message-ID: Subject: Re: [C++0x] avoid extra tentative parse in range-based for loops From: Rodrigo Rivas To: Paolo Bonzini Cc: Jason Merrill , gcc-patches@gcc.gnu.org, Magnus Fromreide 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 What about this? Changelog: gcc/cp/ 2011-01-13 Rodrigo Rivas Costa * parser.c (cp_parser_range_for): Remove the "unused variable" warning workaround. diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index 061e8cc..41f82ac 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -8760,15 +8760,6 @@ cp_parser_range_for (cp_parser *parser, tree scope, tree init, tree range_decl) { tree stmt, range_expr; - /* If the variable from a range-for is not actually used, GCC would issue - "unused variable" warnings, and the user could do little to prevent them. - So we always mark it as used. */ - if (range_decl != error_mark_node) - { - TREE_USED (range_decl) = 1; - DECL_READ_P (range_decl) = 1; - } - if (cp_lexer_next_token_is (parser->lexer, CPP_OPEN_BRACE)) { bool expr_non_constant_p;