From patchwork Thu Feb 10 23:58:41 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Lance Taylor X-Patchwork-Id: 82697 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 DECA8B70E9 for ; Fri, 11 Feb 2011 10:58:55 +1100 (EST) Received: (qmail 14457 invoked by alias); 10 Feb 2011 23:58:53 -0000 Received: (qmail 14449 invoked by uid 22791); 10 Feb 2011 23:58:53 -0000 X-SWARE-Spam-Status: No, hits=-3.1 required=5.0 tests=AWL, BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, RCVD_IN_DNSWL_LOW, SPF_HELO_PASS, TW_FN, 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; Thu, 10 Feb 2011 23:58:49 +0000 Received: from kpbe11.cbf.corp.google.com (kpbe11.cbf.corp.google.com [172.25.105.75]) by smtp-out.google.com with ESMTP id p1ANwkEY024545 for ; Thu, 10 Feb 2011 15:58:46 -0800 Received: from gxk8 (gxk8.prod.google.com [10.202.11.8]) by kpbe11.cbf.corp.google.com with ESMTP id p1ANwiO0029731 (version=TLSv1/SSLv3 cipher=RC4-SHA bits=128 verify=NOT) for ; Thu, 10 Feb 2011 15:58:44 -0800 Received: by gxk8 with SMTP id 8so905031gxk.41 for ; Thu, 10 Feb 2011 15:58:44 -0800 (PST) Received: by 10.91.10.7 with SMTP id n7mr34171agi.30.1297382323976; Thu, 10 Feb 2011 15:58:43 -0800 (PST) Received: from coign.google.com (dhcp-172-22-125-221.mtv.corp.google.com [172.22.125.221]) by mx.google.com with ESMTPS id m49sm117434yha.2.2011.02.10.15.58.43 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 10 Feb 2011 15:58:43 -0800 (PST) From: Ian Lance Taylor To: gcc-patches@gcc.gnu.org, gofrontend-dev@googlegroups.com Subject: go patch committed: Don't crash on erroneous thunk Date: Thu, 10 Feb 2011 15:58:41 -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 compiler avoids a crash on an erroneous thunk. Bootstrapped and ran Go testsuite on x86_64-unknown-linux-gnu. Committed to mainline. Ian diff -r a9fb713eecf6 go/statements.cc --- a/go/statements.cc Thu Feb 10 15:41:00 2011 -0800 +++ b/go/statements.cc Thu Feb 10 15:52:49 2011 -0800 @@ -1776,8 +1776,13 @@ // Now that we know the types of the call, build the struct used to // pass parameters. - Function_type* fntype = - this->call_->call_expression()->get_function_type(); + Call_expression* ce = this->call_->call_expression(); + if (ce == NULL) + { + gcc_assert(this->call_->is_error_expression()); + return; + } + Function_type* fntype = ce->get_function_type(); if (fntype != NULL && !this->is_simple(fntype)) this->struct_type_ = this->build_struct(fntype); } @@ -1788,6 +1793,11 @@ Thunk_statement::do_check_types(Gogo*) { Call_expression* ce = this->call_->call_expression(); + if (ce == NULL) + { + gcc_assert(this->call_->is_error_expression()); + return; + } Function_type* fntype = ce->get_function_type(); if (fntype != NULL && fntype->is_method()) {