From patchwork Thu Feb 24 04:02:36 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: 84316 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 9BB23B7184 for ; Thu, 24 Feb 2011 15:02:55 +1100 (EST) Received: (qmail 11946 invoked by alias); 24 Feb 2011 04:02:53 -0000 Received: (qmail 11932 invoked by uid 22791); 24 Feb 2011 04:02:52 -0000 X-SWARE-Spam-Status: No, hits=-2.0 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; Thu, 24 Feb 2011 04:02:43 +0000 Received: from wpaz17.hot.corp.google.com (wpaz17.hot.corp.google.com [172.24.198.81]) by smtp-out.google.com with ESMTP id p1O42e9V018811 for ; Wed, 23 Feb 2011 20:02:40 -0800 Received: from vxc38 (vxc38.prod.google.com [10.241.33.166]) by wpaz17.hot.corp.google.com with ESMTP id p1O42Eue021547 (version=TLSv1/SSLv3 cipher=RC4-SHA bits=128 verify=NOT) for ; Wed, 23 Feb 2011 20:02:39 -0800 Received: by vxc38 with SMTP id 38so149719vxc.11 for ; Wed, 23 Feb 2011 20:02:39 -0800 (PST) Received: by 10.52.161.138 with SMTP id xs10mr541834vdb.185.1298520159174; Wed, 23 Feb 2011 20:02:39 -0800 (PST) Received: from coign.google.com ([72.14.228.1]) by mx.google.com with ESMTPS id o13sm4026229vch.40.2011.02.23.20.02.38 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 23 Feb 2011 20:02:38 -0800 (PST) From: Ian Lance Taylor To: gcc-patches@gcc.gnu.org, gofrontend-dev@googlegroups.com Subject: Go patch committed: Don't crash on type switch of untyped value Date: Wed, 23 Feb 2011 20:02:36 -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 crashing on a type switch of an untyped value. Bootstrapped and ran Go testsuite on x86_64-unknown-linux-gnu. Committed to mainline. Ian diff -r 50b98fea9d3b go/statements.cc --- a/go/statements.cc Wed Feb 23 19:52:03 2011 -0800 +++ b/go/statements.cc Wed Feb 23 19:58:43 2011 -0800 @@ -3911,7 +3911,11 @@ if (val_type->is_nil_type()) rhs = Expression::make_nil(loc); else - rhs = Expression::make_type_descriptor(val_type, loc); + { + if (val_type->is_abstract()) + val_type = val_type->make_non_abstract_type(); + rhs = Expression::make_type_descriptor(val_type, loc); + } Statement* s = Statement::make_assignment(lhs, rhs, loc); b->add_statement(s); }