From patchwork Fri Nov 16 16:31:07 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Lance Taylor X-Patchwork-Id: 199683 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 D8B0B2C0093 for ; Sat, 17 Nov 2012 03:31:18 +1100 (EST) Comment: DKIM? See http://www.dkim.org DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=gcc.gnu.org; s=default; x=1353688279; h=Comment: DomainKey-Signature:Received:Received:Received:Received:Received: Received:From:To:Subject:Date:Message-ID:User-Agent:MIME-Version: Content-Type:Mailing-List:Precedence:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:Sender:Delivered-To; bh=8k6PmVW WdsCsNncrp6O9FAJ8yNM=; b=GSD0an5UPkfXcS/+vjpJPenyLS4fHJVi6FyJZw3 IDNJGWHfewCxp/08jpvFzju7qcRsPURtPt4J83CfpzDda1nAOCzUKDlCGNWXTWf3 x+ZGC+PiljHXaZUA0bazFlzl8LsBgDftMi/Kt3EXJNh0DsAVMuay47mGdGu4s70k Ne/A= Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=default; d=gcc.gnu.org; h=Received:Received:X-SWARE-Spam-Status:X-Spam-Check-By:Received:Received:X-Google-DKIM-Signature:Received:Received:From:To:Subject:Date:Message-ID:User-Agent:MIME-Version:Content-Type:X-Gm-Message-State:X-IsSubscribed:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=iNqa9RyoHujgIXi+8VnaG9rp4HvpAJpbsh5ZusvSCgegAw+mFwMzJR6Cp+uW+X KrtN8X0tfBgednG51wSjoJSy3ZH7a1xMcC3y4z+ZfgVrrUBOOME+zWh5bknbuxRv 9/5mWF0oJAUBRbBDfMXODdOn6xxwx0CW44vBYv+113Ys8=; Received: (qmail 11200 invoked by alias); 16 Nov 2012 16:31:15 -0000 Received: (qmail 11192 invoked by uid 22791); 16 Nov 2012 16:31:15 -0000 X-SWARE-Spam-Status: No, hits=-4.5 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, KHOP_RCVD_TRUST, RCVD_IN_DNSWL_LOW, RCVD_IN_HOSTKARMA_YE, RP_MATCHES_RCVD, T_TVD_MIME_NO_HEADERS X-Spam-Check-By: sourceware.org Received: from mail-pa0-f47.google.com (HELO mail-pa0-f47.google.com) (209.85.220.47) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 16 Nov 2012 16:31:09 +0000 Received: by mail-pa0-f47.google.com with SMTP id fa11so1867673pad.20 for ; Fri, 16 Nov 2012 08:31:09 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:to:subject:date:message-id:user-agent:mime-version :content-type:x-gm-message-state; bh=Q6GG4AWsBX8CtWlxkvHODprtz54z+bgPJ718YotTgFk=; b=jy8YztP1nUWVL8CC2d9Sq+6AdfiplT2MTGVWnwMDPKUZNBFHCFH0ndq26Jw4+omQgq e/5XNSj9zKITbBQDwqg7TfVc5ooBhoHYTiLAN1TtAVY3TNs1jo0IjMduhj0MAGZQA0Z8 zntRT0zjxUGgmThD1daACxWJK42uASaUjx3Eg609au8dDNzblF3WJgaj0xnoSykfVipC ODEbIJyEAUco5N53/ea540gCw6p7OmDHRYN003F8Tb74uoZsClEBX2ZC+kqIRskrPELm GZbkEyOec5baHmjHnDzGCXbvWPxW2gU+2GlUnfuYOG/NIpoFnXeeGZJTuknboa6f9/Uk dm+g== Received: by 10.68.245.169 with SMTP id xp9mr16582202pbc.142.1353083469059; Fri, 16 Nov 2012 08:31:09 -0800 (PST) Received: from coign.google.com ([2620:0:1000:147c:224:d7ff:fe8f:f634]) by mx.google.com with ESMTPS id v9sm1317805paz.6.2012.11.16.08.31.08 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 16 Nov 2012 08:31:08 -0800 (PST) From: Ian Lance Taylor To: gcc-patches@gcc.gnu.org, gofrontend-dev@googlegroups.com Subject: Go patch committed: Don't remove float conversion of typed constant Date: Fri, 16 Nov 2012 08:31:07 -0800 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) MIME-Version: 1.0 X-Gm-Message-State: ALoCoQla3vDQm/doZK9l5OH+YAVNjpg/46d8b/I4hcWNO+AZnxTljzzMW0S8aKCCcPXX7aLJENiKmlBiVmK0tI80fYweWYScKuh/NbwQStMkZQZldIAoiPZtY9QjDvUYOgjVkX2J4CeAjgvn2d4Pk0rc9j2UlYovRO/2nsklJgLLCjsqkRpdnIhfI1rH+XC/pcYRhLk7fb0B 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 fixes the case of float64(float32(1.0)). Here float32(1.0) is a typed constant. The compiler was translating that to float64(1.0), which is not correct. Bootstrapped and ran Go testsuite on x86_64-unknown-linux-gnu. Committed to mainline and 4.7 branch. Ian Index: gcc/go/gofrontend/expressions.cc =================================================================== --- gcc/go/gofrontend/expressions.cc (revision 193484) +++ gcc/go/gofrontend/expressions.cc (working copy) @@ -2962,6 +2962,46 @@ Type_conversion_expression::do_lower(Gog { if (!nc.set_type(type, true, location)) return Expression::make_error(location); + + // Don't simply convert to or from a float or complex type + // with a different size. That may change the value. + Type* vtype = val->type(); + if (vtype->is_abstract()) + ; + else if (type->float_type() != NULL) + { + if (vtype->float_type() != NULL) + { + if (type->float_type()->bits() != vtype->float_type()->bits()) + return this; + } + else if (vtype->complex_type() != NULL) + { + if (type->float_type()->bits() * 2 + != vtype->complex_type()->bits()) + return this; + } + } + else if (type->complex_type() != NULL) + { + if (vtype->complex_type() != NULL) + { + if (type->complex_type()->bits() + != vtype->complex_type()->bits()) + return this; + } + else if (vtype->float_type() != NULL) + { + if (type->complex_type()->bits() + != vtype->float_type()->bits() * 2) + return this; + } + } + else if (vtype->float_type() != NULL) + return this; + else if (vtype->complex_type() != NULL) + return this; + return nc.expression(location); } }