From patchwork Tue Dec 21 23:33:54 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: 76345 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 4B222B70A3 for ; Wed, 22 Dec 2010 10:34:09 +1100 (EST) Received: (qmail 18959 invoked by alias); 21 Dec 2010 23:34:07 -0000 Received: (qmail 18853 invoked by uid 22791); 21 Dec 2010 23:34:06 -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; Tue, 21 Dec 2010 23:34:01 +0000 Received: from hpaq14.eem.corp.google.com (hpaq14.eem.corp.google.com [172.25.149.14]) by smtp-out.google.com with ESMTP id oBLNXwKA023315 for ; Tue, 21 Dec 2010 15:33:58 -0800 Received: from iwn37 (iwn37.prod.google.com [10.241.68.101]) by hpaq14.eem.corp.google.com with ESMTP id oBLNXuGA025887 (version=TLSv1/SSLv3 cipher=RC4-MD5 bits=128 verify=NOT) for ; Tue, 21 Dec 2010 15:33:57 -0800 Received: by iwn37 with SMTP id 37so5101317iwn.11 for ; Tue, 21 Dec 2010 15:33:56 -0800 (PST) Received: by 10.42.219.2 with SMTP id hs2mr6297119icb.365.1292974436430; Tue, 21 Dec 2010 15:33:56 -0800 (PST) Received: from coign.google.com (dhcp-172-22-122-207.mtv.corp.google.com [172.22.122.207]) by mx.google.com with ESMTPS id u9sm859451icz.0.2010.12.21.15.33.55 (version=TLSv1/SSLv3 cipher=RC4-MD5); Tue, 21 Dec 2010 15:33:56 -0800 (PST) From: Ian Lance Taylor To: gcc-patches@gcc.gnu.org, gofrontend-dev@googlegroups.com Subject: Go patch committed: Don't permit assigning abstract string to numeric Date: Tue, 21 Dec 2010 15:33:54 -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 fixes a bug in the Go frontend: it permitted assigning an abstract string (or bool) to a variable with numeric type. Bootstrapped and ran Go testsuite on x86_64-unknown-linux-gnu. Committed to mainline. Ian diff -r 51b5b97197e8 go/types.cc --- a/go/types.cc Tue Dec 21 15:18:33 2010 -0800 +++ b/go/types.cc Tue Dec 21 15:31:03 2010 -0800 @@ -543,15 +543,17 @@ || lhs->interface_type() != NULL)) return true; - // An untyped constant may be assigned to a numeric type if it is - // representable in that type. - if (rhs->is_abstract() + // An untyped numeric constant may be assigned to a numeric type if + // it is representable in that type. + if ((rhs->is_abstract() + && (rhs->integer_type() != NULL + || rhs->float_type() != NULL + || rhs->complex_type() != NULL)) && (lhs->integer_type() != NULL || lhs->float_type() != NULL || lhs->complex_type() != NULL)) return true; - // Give some better error messages. if (reason != NULL && reason->empty()) {