From patchwork Wed Dec 15 00:09:18 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: 75590 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 05771B6F11 for ; Wed, 15 Dec 2010 11:09:35 +1100 (EST) Received: (qmail 26542 invoked by alias); 15 Dec 2010 00:09:32 -0000 Received: (qmail 26533 invoked by uid 22791); 15 Dec 2010 00:09:31 -0000 X-SWARE-Spam-Status: No, hits=-2.3 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; Wed, 15 Dec 2010 00:09:23 +0000 Received: from wpaz37.hot.corp.google.com (wpaz37.hot.corp.google.com [172.24.198.101]) by smtp-out.google.com with ESMTP id oBF09LIj026668 for ; Tue, 14 Dec 2010 16:09:21 -0800 Received: from iyj21 (iyj21.prod.google.com [10.241.51.85]) by wpaz37.hot.corp.google.com with ESMTP id oBF097TE005466 for ; Tue, 14 Dec 2010 16:09:20 -0800 Received: by iyj21 with SMTP id 21so582065iyj.8 for ; Tue, 14 Dec 2010 16:09:20 -0800 (PST) Received: by 10.42.241.73 with SMTP id ld9mr5041413icb.265.1292371760314; Tue, 14 Dec 2010 16:09:20 -0800 (PST) Received: from coign.google.com (dhcp-172-22-122-182.mtv.corp.google.com [172.22.122.182]) by mx.google.com with ESMTPS id d21sm411720ibg.15.2010.12.14.16.09.19 (version=TLSv1/SSLv3 cipher=RC4-MD5); Tue, 14 Dec 2010 16:09:19 -0800 (PST) From: Ian Lance Taylor To: gcc-patches@gcc.gnu.org, gofrontend-dev@googlegroups.com Subject: Go patch committed: Don't crash initializing array of invalid type Date: Tue, 14 Dec 2010 16:09:18 -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 when zero-initializing an array of an invalid type. Bootstrapped and ran Go testsuite on x86_64-unknown-linux-gnu. Committed to mainline. Ian diff -r 667e7f7457b5 go/types.cc --- a/go/types.cc Tue Dec 14 15:54:49 2010 -0800 +++ b/go/types.cc Tue Dec 14 16:05:01 2010 -0800 @@ -4421,8 +4421,13 @@ tree value = this->element_type_->get_init_tree(gogo, is_clear); if (value == NULL) return NULL; + if (value == error_mark_node) + return error_mark_node; tree length_tree = this->get_length_tree(gogo); + if (length_tree == error_mark_node) + return error_mark_node; + length_tree = fold_convert(sizetype, length_tree); tree range = build2(RANGE_EXPR, sizetype, size_zero_node, fold_build2(MINUS_EXPR, sizetype,