From patchwork Thu Oct 26 23:04:18 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Lance Taylor X-Patchwork-Id: 830967 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-465290-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="duOEwxV9"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3yNMyn0CN1z9s74 for ; Fri, 27 Oct 2017 10:04:31 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :mime-version:from:date:message-id:subject:to:content-type; q= dns; s=default; b=MDIuL/cgBoYHZW2LSSwHnvIoZHX5KXhr2ArTsc1e2h0UhT yUcQusTW4ILC8ro1uDZFW2NFglWvwA4iTsk17O+mir8Lmwn92qJaSvq/dm67LrrC lPqQgc6R8TiQwN+BOg3sXat1YH6AFft7riqhWJav6XtsJBkBe4KPuTOp6Eypc= 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 :mime-version:from:date:message-id:subject:to:content-type; s= default; bh=H6ZhoW5xECVBNJSaUfDZP5kz+dc=; b=duOEwxV9kc0EMF1xRzcZ RyUFJZum3Y3IU8QM0PSTxbY6PnhJu5nd8PdX38CR1DtWxae+JoXYBUep04ujLgxh XtvsIRgint9BKjYlWlZm63/gE8AmUMCRz5Ri47tyKjAt/QZBlqdOkuwU4E0X6NLC QcoIKAKVGRvu8lWm0UXqkJQ= Received: (qmail 117031 invoked by alias); 26 Oct 2017 23:04:24 -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 117020 invoked by uid 89); 26 Oct 2017 23:04:24 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-10.7 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS, RCVD_IN_DNSWL_NONE, RCVD_IN_SORBS_SPAM, SPF_PASS autolearn=ham version=3.3.2 spammy=HX-Received:10.80.221.11, HX-Received:sk:t11mr29 X-HELO: mail-wm0-f51.google.com Received: from mail-wm0-f51.google.com (HELO mail-wm0-f51.google.com) (74.125.82.51) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 26 Oct 2017 23:04:21 +0000 Received: by mail-wm0-f51.google.com with SMTP id z3so383235wme.5 for ; Thu, 26 Oct 2017 16:04:21 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=n8nIVHCvTlaT7dXenag0WTfXuaUPnzsMzLw02Go4cY4=; b=OLEF24JgYi6dVM85iJZmoGZxesqz/ZeknCxMGU0jG2kkmMt0h7ncGJx8bi5JOOeTuc Jk/muUHUCGsraJCd5iKprnS3xX1JlvLn1w+cakX6XE6g4KJXuvA7MlNmNSaDkU4lE8p/ wRxXHaJme/IIl1Ahdlw76b8fGMaGAgYc5zxKN7pdo+hJR9f+r3Ij64+VmBQlU0brT9Ng l3r3y0zZtzp/GHhz1e+ru0ESPOCVqntUPzqVFPiHIH9aUh36COZDXHjehPriRGsDOoo4 vr7N8S+82kJgS6LUm2j7ZixQ9CLQ5HqMMTxh/nxa/zvIQwJsolWJXaP6L2HLel7duOTr +ZbQ== X-Gm-Message-State: AMCzsaVBTV0XVmSwa6BockVlrkKv9nCcapAEHcXT81apKCBkWjcj/Svj frJiEtVJj6zmwo4kFoLdhTQqtMV25Z7nv0PYsdG75Egg X-Google-Smtp-Source: ABhQp+QEPwQ0CjNTf4GG7MijcO/6dgZ9hDGQDc0KVNRbazix455YGQZxRI/bhlVD6W2gpMi1DEUDxhNklA9Gmu5WR5I= X-Received: by 10.80.221.11 with SMTP id t11mr29720707edk.84.1509059059464; Thu, 26 Oct 2017 16:04:19 -0700 (PDT) MIME-Version: 1.0 Received: by 10.80.179.240 with HTTP; Thu, 26 Oct 2017 16:04:18 -0700 (PDT) From: Ian Lance Taylor Date: Thu, 26 Oct 2017 16:04:18 -0700 Message-ID: Subject: Go patch committed: Explicitly convert between type aliases To: gcc-patches , "gofrontend-dev@googlegroups.com" This patch adds an explicit conversion between type aliases. Otherwise we can get a crash in the backend when GCC sees a fold_convert_loc between two record types that the GCC backend appear to be different. Adding the explicit conversion will insert a VIEW_CONVERT_EXPR where needed. The test case is https://golang.org/cl/73790. Bootstrapped and ran Go testsuite on x86_64-pc-linux-gnu. Committed to mainline. Ian Index: gcc/go/gofrontend/MERGE =================================================================== --- gcc/go/gofrontend/MERGE (revision 254090) +++ gcc/go/gofrontend/MERGE (working copy) @@ -1,4 +1,4 @@ -a409ac2c78899e638a014c97891925bec93cb3ad +64d570c590a76921cbdca4efb22e4675e19cc809 The first line of this file holds the git revision number of the last merge done from the gofrontend repository. Index: gcc/go/gofrontend/expressions.cc =================================================================== --- gcc/go/gofrontend/expressions.cc (revision 254090) +++ gcc/go/gofrontend/expressions.cc (working copy) @@ -144,8 +144,8 @@ Expression::convert_for_assignment(Gogo* || rhs->is_error_expression()) return Expression::make_error(location); - if (lhs_type->forwarded() != rhs_type->forwarded() - && lhs_type->interface_type() != NULL) + bool are_identical = Type::are_identical(lhs_type, rhs_type, false, NULL); + if (!are_identical && lhs_type->interface_type() != NULL) { if (rhs_type->interface_type() == NULL) return Expression::convert_type_to_interface(lhs_type, rhs, location); @@ -153,8 +153,7 @@ Expression::convert_for_assignment(Gogo* return Expression::convert_interface_to_interface(lhs_type, rhs, false, location); } - else if (lhs_type->forwarded() != rhs_type->forwarded() - && rhs_type->interface_type() != NULL) + else if (!are_identical && rhs_type->interface_type() != NULL) return Expression::convert_interface_to_type(lhs_type, rhs, location); else if (lhs_type->is_slice_type() && rhs_type->is_nil_type()) { @@ -165,8 +164,15 @@ Expression::convert_for_assignment(Gogo* } else if (rhs_type->is_nil_type()) return Expression::make_nil(location); - else if (Type::are_identical(lhs_type, rhs_type, false, NULL)) + else if (are_identical) { + if (lhs_type->forwarded() != rhs_type->forwarded()) + { + // Different but identical types require an explicit + // conversion. This happens with type aliases. + return Expression::make_cast(lhs_type, rhs, location); + } + // No conversion is needed. return rhs; }