From patchwork Fri Nov 8 05:46:23 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Lance Taylor X-Patchwork-Id: 289695 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]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id A3E202C00A3 for ; Fri, 8 Nov 2013 16:46:52 +1100 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:subject:date:message-id:mime-version:content-type; q=dns; s= default; b=d9AIrW0PLlKVy7LTXJC1NBxKB4MnuodwNUofnE/ntAGllG0xZkF8M e7+nUOieauqvxVNQrTlc8A8CQQ/f5Ghr/mT+ppnI0kMZ9aDm/3XzwcdWFpHJbDTQ OW22cBUH0cN/sp3D+o0OB13WMemvWaMUC31kf46XLsow4B/typODzU= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:subject:date:message-id:mime-version:content-type; s= default; bh=b5Zg2EXcGz8RypJXiNU+/q8mbdQ=; b=SP9CMtnEmxWNbQTk50mv hG9Fu4azF2hOTNNeIDLUSCj6+VXwcMowlVo5aLUGd/qCeTzgmpmDZgguA7KT+Zv+ XPXje4Lz/dJ++DtAibUmdX8qbYdy847TR8vUGG232V0yXWcVdGQCj/WPwrDfqg2z 7ZI3zZEb+AmJZ9KsSt+gFKs= Received: (qmail 15275 invoked by alias); 8 Nov 2013 05:46:37 -0000 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 Received: (qmail 15260 invoked by uid 89); 8 Nov 2013 05:46:36 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=1.6 required=5.0 tests=AWL, BAYES_00, RDNS_NONE, SPAM_SUBJECT, SPF_PASS, T_TVD_MIME_NO_HEADERS, URIBL_BLOCKED autolearn=no version=3.3.2 X-HELO: mail-pd0-f171.google.com Received: from Unknown (HELO mail-pd0-f171.google.com) (209.85.192.171) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Fri, 08 Nov 2013 05:46:35 +0000 Received: by mail-pd0-f171.google.com with SMTP id w10so1660615pde.2 for ; Thu, 07 Nov 2013 21:46:27 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:subject:date:message-id:user-agent :mime-version:content-type; bh=bNUWCQwnaiLYWXfo+5144gISf03tEQawk09HcIGwzME=; b=FqkRQnGumUDqxtbKmv/4IaIvePJ9tenRgTCR8/vK5xLBFkWE8QZPa2f2PeaqxS28Zx +hqLbi8YzaJXyL5vkaKjpFy3y0hTO/k5YcmwoQljcx96lmN0ROFdFYsg9HnERZKGyOpK Z/3htJMD0Sq/JEfKxJQteGRwwjPOeMz5et5SoMEDtvXOAIZ4qeGz7VW1djqrBn+/NSbv ODR4jiYGObG6Bj68w6diNwtERGQ8TP5j+ppVn3EBnfk21Bfh1KhFWnhJyaYlS6gIf5VL 9Laq6vIKM9L3dvB6ubShOKyV3U6evLyuiu2VAoeapOI2O8C1nE/KPQ8gm6v/TbaUVZPt I2bw== X-Gm-Message-State: ALoCoQlED0PDzmS/pdZLVOTQ9iZQ/gPbyRDN6hO+JYp+shtdn5wvxZlgOt5c91I1CTV3zgkttCJfDfZq44q3d6zynIZwE+Uu6fpg3C3B0ieC1hRTbEUe4iYsrwP/u7jeMeELaE0Hvo0XRz0lewhjlednbO0YUXCbkZkOQeXjKwXrnwyF8TWPaNFAhKxftqOJzQhmxCWxx/F3nkfY942TIx6wjB54ee8ZMg== X-Received: by 10.68.4.232 with SMTP id n8mr13139918pbn.9.1383889587111; Thu, 07 Nov 2013 21:46:27 -0800 (PST) Received: from iant-glaptop.roam.corp.google.com.google.com ([172.26.48.81]) by mx.google.com with ESMTPSA id hu10sm9329713pbc.11.2013.11.07.21.46.25 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Thu, 07 Nov 2013 21:46:26 -0800 (PST) From: Ian Lance Taylor To: gcc-patches@gcc.gnu.org, gofrontend-dev@googlegroups.com Subject: Go patch committed: Correct types in type conversion Date: Thu, 07 Nov 2013 21:46:23 -0800 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.3 (gnu/linux) MIME-Version: 1.0 X-IsSubscribed: yes This patch to the Go frontend fixes the type returned when a type conversion has to make a function call. I have a test case that I will commit to the master testsuite after the Go 1.2 release (the test case is simply "return []byte(s)[0]"). Bootstrapped and ran Go testsuite on x86_64-unknown-linux-gnu. Committed to mainline. Ian diff -r 3b96b48543bd go/expressions.cc --- a/go/expressions.cc Thu Nov 07 15:35:59 2013 -0800 +++ b/go/expressions.cc Thu Nov 07 20:39:58 2013 -0800 @@ -3351,9 +3351,10 @@ return se->get_tree(context); } - Call_expression* i2s_expr = + Expression* i2s_expr = Runtime::make_call(Runtime::INT_TO_STRING, this->location(), 1, this->expr_); + i2s_expr = Expression::make_cast(type, i2s_expr, this->location()); ret = i2s_expr->get_tree(context); } else if (type->is_string_type() && expr_type->is_slice_type()) @@ -3405,7 +3406,7 @@ Type* e = type->array_type()->element_type()->forwarded(); go_assert(e->integer_type() != NULL); - Call_expression* s2a_expr; + Expression* s2a_expr; if (e->integer_type()->is_byte()) s2a_expr = Runtime::make_call(Runtime::STRING_TO_BYTE_ARRAY, this->location(), 1, this->expr_); @@ -3415,6 +3416,8 @@ s2a_expr = Runtime::make_call(Runtime::STRING_TO_INT_ARRAY, this->location(), 1, this->expr_); } + s2a_expr = Expression::make_unsafe_cast(type, s2a_expr, + this->location()); ret = s2a_expr->get_tree(context); } else if ((type->is_unsafe_pointer_type()