From patchwork Sat Jan 31 00:20:13 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Lance Taylor X-Patchwork-Id: 435067 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]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 5A20514017A for ; Sat, 31 Jan 2015 11:20:50 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :mime-version:date:message-id:subject:from:to:content-type; q= dns; s=default; b=El2iqxm2OxtyWnqcbBzq15/IKazwb/qIjypP9qzLyAWtMS 9ehKDdstCRiteiY7DwuxPNoIuPniHEV8nc+mMaMB3XraIpHEqLD22Y8sfzAmMa4N mo4y7eQ4CcBCNzMHXIn09AwV07+zAb4/u6heKDxFqr03mEHoWKysSwqwQDXrI= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :mime-version:date:message-id:subject:from:to:content-type; s= default; bh=8cmwNLDLJ97+QFafqNaqwwh/1gA=; b=RaCec+czUQuZRWkLUACv B61c4a4RLC5l11rcPvUoEVUFhCCu+M1EnUbucox6r6ws2qGqOTsBQ/lqKfsySlD8 YlRVC2nRTIXCuo+zYzlctfMt6NK2eGocaGj41e1+ucEXICeVQNOiKFTZ4RdH4zCD iGZmIYjmoArar2pw7DwJhm0= Received: (qmail 24938 invoked by alias); 31 Jan 2015 00:20:18 -0000 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 Received: (qmail 24901 invoked by uid 89); 31 Jan 2015 00:20:17 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.4 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-yk0-f170.google.com Received: from mail-yk0-f170.google.com (HELO mail-yk0-f170.google.com) (209.85.160.170) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Sat, 31 Jan 2015 00:20:15 +0000 Received: by mail-yk0-f170.google.com with SMTP id q9so18420616ykb.1 for ; Fri, 30 Jan 2015 16:20:13 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:date:message-id:subject:from:to :content-type; bh=4qTTnNBXaA5kOCB4f5s0Dtg0FKUd/LFeDq45H0RR/ZQ=; b=mniqhgIsqOMYPJ+BOc1hUnec/9q7IeTdVDPSbh4iIQEqWRA2lVPH+psq6McT8t9N8f E+58kEQpTzcEyphc10MFmMJe7F/FWXaGc9vuyk80W1R2RRK9wCPQ/VeQ/Zxchacpj7Xn m2ckIDPU+4TfXJoBf7hDWmtz6zuN3+b+jGWRRkge5qGLy7vhzmWD+7oNQQNmiqdumhth EM+ffU/9fs9aQr3U1cUKIa+7zl1wuS3ORfsWfwHGvHBXUPCs0P/Ywk0B+OKQSgppJpOj hu202Lv8S8vQOyca6Iw6UHA4fSbgVxZSPkTir4PsUVnSyGaQ+h6Lm3OAROQm/AmUOI7H GPEA== X-Gm-Message-State: ALoCoQlm3cFyDs5Dmnjzki5OZj4DJKSOuI3BPwjFZugqktFbH/IECRNcVfKUA6vIxEKdlHmWTtBe MIME-Version: 1.0 X-Received: by 10.236.20.229 with SMTP id p65mr4045415yhp.161.1422663613577; Fri, 30 Jan 2015 16:20:13 -0800 (PST) Received: by 10.170.69.193 with HTTP; Fri, 30 Jan 2015 16:20:13 -0800 (PST) Date: Fri, 30 Jan 2015 16:20:13 -0800 Message-ID: Subject: Go patch committed: treat map index expressions as lvalues in range expressions From: Ian Lance Taylor To: gcc-patches , "gofrontend-dev@googlegroups.com" This patch by Chris Manghane fixes a bug in the gofrontend in which map index expressions were not treated as lvalues in range expressions. That is, for m[0] = range s did not work. This was Go issue 9695. Bootstrapped and ran Go testsuite on x86_64-unknown-linux-gnu. Committed to mainline. Ian diff -r 172f17c15975 go/parse.cc --- a/go/parse.cc Fri Jan 30 08:04:31 2015 -0800 +++ b/go/parse.cc Fri Jan 30 16:17:50 2015 -0800 @@ -4011,36 +4011,8 @@ token = this->advance_token(); - if (p_range_clause != NULL && token->is_keyword(KEYWORD_RANGE)) - { - if (op != OPERATOR_EQ) - error_at(this->location(), "range clause requires %<=%>"); - this->range_clause_expr(lhs, p_range_clause); - return; - } - - Expression_list* vals = this->expression_list(NULL, false, - may_be_composite_lit); - - // We've parsed everything; check for errors. - if (lhs == NULL || vals == NULL) + if (lhs == NULL) return; - for (Expression_list::const_iterator pe = lhs->begin(); - pe != lhs->end(); - ++pe) - { - if ((*pe)->is_error_expression()) - return; - if (op != OPERATOR_EQ && (*pe)->is_sink_expression()) - error_at((*pe)->location(), "cannot use _ as value"); - } - for (Expression_list::const_iterator pe = vals->begin(); - pe != vals->end(); - ++pe) - { - if ((*pe)->is_error_expression()) - return; - } // Map expressions act differently when they are lvalues. for (Expression_list::iterator plv = lhs->begin(); @@ -4049,6 +4021,37 @@ if ((*plv)->index_expression() != NULL) (*plv)->index_expression()->set_is_lvalue(); + if (p_range_clause != NULL && token->is_keyword(KEYWORD_RANGE)) + { + if (op != OPERATOR_EQ) + error_at(this->location(), "range clause requires %<=%>"); + this->range_clause_expr(lhs, p_range_clause); + return; + } + + Expression_list* vals = this->expression_list(NULL, false, + may_be_composite_lit); + + // We've parsed everything; check for errors. + if (vals == NULL) + return; + for (Expression_list::const_iterator pe = lhs->begin(); + pe != lhs->end(); + ++pe) + { + if ((*pe)->is_error_expression()) + return; + if (op != OPERATOR_EQ && (*pe)->is_sink_expression()) + error_at((*pe)->location(), "cannot use _ as value"); + } + for (Expression_list::const_iterator pe = vals->begin(); + pe != vals->end(); + ++pe) + { + if ((*pe)->is_error_expression()) + return; + } + Call_expression* call; Index_expression* map_index; Receive_expression* receive;