From patchwork Thu Mar 3 00:42:13 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: 85196 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 2C314B6EFF for ; Thu, 3 Mar 2011 11:42:48 +1100 (EST) Received: (qmail 32197 invoked by alias); 3 Mar 2011 00:42:47 -0000 Received: (qmail 32189 invoked by uid 22791); 3 Mar 2011 00:42:47 -0000 X-SWARE-Spam-Status: No, hits=-2.2 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) (216.239.44.51) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 03 Mar 2011 00:42:42 +0000 Received: from wpaz21.hot.corp.google.com (wpaz21.hot.corp.google.com [172.24.198.85]) by smtp-out.google.com with ESMTP id p230gebG022626 for ; Wed, 2 Mar 2011 16:42:41 -0800 Received: from iyj8 (iyj8.prod.google.com [10.241.51.72]) by wpaz21.hot.corp.google.com with ESMTP id p230eW9c028324 (version=TLSv1/SSLv3 cipher=RC4-SHA bits=128 verify=NOT) for ; Wed, 2 Mar 2011 16:42:40 -0800 Received: by iyj8 with SMTP id 8so594622iyj.37 for ; Wed, 02 Mar 2011 16:42:39 -0800 (PST) Received: by 10.231.13.138 with SMTP id c10mr421042iba.97.1299112959553; Wed, 02 Mar 2011 16:42:39 -0800 (PST) Received: from coign.google.com ([67.218.107.6]) by mx.google.com with ESMTPS id d21sm399367ibg.9.2011.03.02.16.42.36 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 02 Mar 2011 16:42:39 -0800 (PST) From: Ian Lance Taylor To: gcc-patches@gcc.gnu.org, gofrontend-dev@googlegroups.com Subject: Go patch committed: Don't crash if constant has undefined type Date: Wed, 02 Mar 2011 16:42:13 -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 crash if a constant has a declared but undefined type. Bootstrapped and ran Go testsuite on x86_64-unknown-linux-gnu. Committed to mainline. Ian diff -r 8ec65d0d172b go/gogo-tree.cc --- a/go/gogo-tree.cc Wed Mar 02 16:12:58 2011 -0800 +++ b/go/gogo-tree.cc Wed Mar 02 16:37:20 2011 -0800 @@ -926,7 +926,16 @@ { Type* type = named_constant->type(); if (type != NULL && !type->is_abstract()) - expr_tree = fold_convert(type->get_tree(gogo), expr_tree); + { + if (!type->is_undefined()) + expr_tree = fold_convert(type->get_tree(gogo), expr_tree); + else + { + // Make sure we report the error. + type->base(); + expr_tree = error_mark_node; + } + } if (expr_tree == error_mark_node) decl = error_mark_node; else if (INTEGRAL_TYPE_P(TREE_TYPE(expr_tree)))