From patchwork Wed Dec 22 16:21:09 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Lance Taylor X-Patchwork-Id: 76430 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 60E18B70A4 for ; Thu, 23 Dec 2010 03:21:28 +1100 (EST) Received: (qmail 9389 invoked by alias); 22 Dec 2010 16:21:23 -0000 Received: (qmail 9378 invoked by uid 22791); 22 Dec 2010 16:21:21 -0000 X-SWARE-Spam-Status: No, hits=-2.9 required=5.0 tests=AWL, BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, SPF_HELO_PASS, T_RP_MATCHES_RCVD, T_TVD_MIME_NO_HEADERS X-Spam-Check-By: sourceware.org Received: from smtp-out.google.com (HELO smtp-out.google.com) (74.125.121.67) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 22 Dec 2010 16:21:16 +0000 Received: from kpbe14.cbf.corp.google.com (kpbe14.cbf.corp.google.com [172.25.105.78]) by smtp-out.google.com with ESMTP id oBMGLDST029044 for ; Wed, 22 Dec 2010 08:21:13 -0800 Received: from pvg7 (pvg7.prod.google.com [10.241.210.135]) by kpbe14.cbf.corp.google.com with ESMTP id oBMGLB43001062 for ; Wed, 22 Dec 2010 08:21:12 -0800 Received: by pvg7 with SMTP id 7so1670759pvg.22 for ; Wed, 22 Dec 2010 08:21:11 -0800 (PST) Received: by 10.142.179.18 with SMTP id b18mr5679244wff.421.1293034871524; Wed, 22 Dec 2010 08:21:11 -0800 (PST) Received: from coign.google.com (dhcp-172-22-121-194.mtv.corp.google.com [172.22.121.194]) by mx.google.com with ESMTPS id e14sm9335801wfg.8.2010.12.22.08.21.10 (version=TLSv1/SSLv3 cipher=RC4-MD5); Wed, 22 Dec 2010 08:21:10 -0800 (PST) From: Ian Lance Taylor To: gcc-patches@gcc.gnu.org, gofrontend-dev@googlegroups.com Subject: Go patch committed: Don't crash if a temporary is not defined Date: Wed, 22 Dec 2010 08:21:09 -0800 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) MIME-Version: 1.0 X-System-Of-Record: true 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 This patch to the Go frontend avoids a compiler crash if a temporary is not defined due to errors. Bootstrapped and ran Go testsuite on x86_64-unknown-linux-gnu. Committed to mainline. Ian diff -r f0539ea34ab9 go/statements.cc --- a/go/statements.cc Wed Dec 22 07:55:23 2010 -0800 +++ b/go/statements.cc Wed Dec 22 08:17:25 2010 -0800 @@ -299,6 +299,19 @@ return this->type_ != NULL ? this->type_ : this->init_->type(); } +// Return the tree for the temporary variable. + +tree +Temporary_statement::get_decl() const +{ + if (this->decl_ == NULL) + { + gcc_assert(saw_errors()); + return error_mark_node; + } + return this->decl_; +} + // Traversal. int diff -r f0539ea34ab9 go/statements.h --- a/go/statements.h Wed Dec 22 07:55:23 2010 -0800 +++ b/go/statements.h Wed Dec 22 08:17:25 2010 -0800 @@ -487,11 +487,7 @@ // Return the tree for the temporary variable itself. This should // not be called until after the statement itself has been expanded. tree - get_decl() const - { - gcc_assert(this->decl_ != NULL); - return this->decl_; - } + get_decl() const; protected: int