From patchwork Sat Sep 9 06:01:38 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: 811909 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-461753-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="dnCMXJZ1"; 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 3xq3VR16F8z9s83 for ; Sat, 9 Sep 2017 16:01:50 +1000 (AEST) 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=n5pcZuEXI4cFFLKI9eJFPNb88lZsQDJQmjckwofuHiv/RZ WAsFyepNtSmZp2E/6nGstW+MDpPnzlERxl+aVuuhCUSC4a8SQZ5K+C2lp9POugeA hBOuq3zcWZA8CL1EguJzoqEN3RBU0fHIUECbuTsDDDTK1r5v9+4x/H7FSz60A= 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=i2epcq3dQtx9Gfywzh2PON8aCWY=; b=dnCMXJZ1v7v9EwCCb3QJ WQik+j5+b8nZ70Mm1NWNvv4+eusl/llc2NTZezm2jMl9WeML7OKg9AZo0JwqjIXe SUO9bv2M99xEFriOzPQaT1Wgdf1kXgwk49m6Jyk0pb7CZqGpwQqkkY2pIIXvLviv VNX9+Xd2BmDf8aXmDnCMd2o= Received: (qmail 130816 invoked by alias); 9 Sep 2017 06:01:42 -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 130802 invoked by uid 89); 9 Sep 2017 06:01:42 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-10.6 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy=pf, H*Ad:D*googlegroups.com, Hx-languages-length:1612 X-HELO: mail-pf0-f181.google.com Received: from mail-pf0-f181.google.com (HELO mail-pf0-f181.google.com) (209.85.192.181) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sat, 09 Sep 2017 06:01:40 +0000 Received: by mail-pf0-f181.google.com with SMTP id e1so7412313pfk.1 for ; Fri, 08 Sep 2017 23:01:40 -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=ohSpqyq6Mfoq8NTxcSyuKDvh1rGCjWbFcTA5R6h787s=; b=d6a50SbQRM1WrFcCkxWZHaK7OMw8jKjgoiqp3XOfMEwbzwzq3H+EP4q7w3iOnYEvwF 5I26VLlHAp8jfrTM3gnM4diJf+pVnQcCO9XfPrKk037a1+EkvKvNvv5rLJJj90P/z7NJ 25hSpzgw7Ak9XBO2jQAp3SSC2AtXdp30wMceBscX4vCbzz1AAaDKkwf9bJiRr4vKWul8 H6JY/qzuGkg87M0UsEIkfHZPmS+pkYqpVK6OY3bo65cCcDM46/fpjQX8yip20Rfyo7pr 9KoaHUOF53XXgrrsSePL3LjwljBzXyYJFLtArVj9x5vQls7y1J25+I1FMq6UbnK6In65 yq4A== X-Gm-Message-State: AHPjjUhsxRpSfGmDDQ7pmc1QvNnFqPZDYS2OnxX15JYVM570w4gf/12V WCUJVbMXb2qet3ogsJ4GZg3tFYdnbH9ukDM= X-Google-Smtp-Source: ADKCNb6JOXpbTLEceNaXDaEH8/CpTlxEMdHsAlVlL1tUGf94+Kk3k5GJaXEjTN7f9ymVxXldkWXLFaG6uN7590c25Ss= X-Received: by 10.84.209.197 with SMTP id y63mr6122948plh.316.1504936898878; Fri, 08 Sep 2017 23:01:38 -0700 (PDT) MIME-Version: 1.0 Received: by 10.100.186.164 with HTTP; Fri, 8 Sep 2017 23:01:38 -0700 (PDT) From: Ian Lance Taylor Date: Fri, 8 Sep 2017 23:01:38 -0700 Message-ID: Subject: Go patch committedd: Don't do implicit double pointer indirection To: gcc-patches , "gofrontend-dev@googlegroups.com" The Go frontend code that lowers field references could sometimes introduce a double pointer indirection in cases where it is not/safe appropriate. For example, in var p **struct { f int } p.f = 0 the assignment LHS was being incorrectly lowered to (*(*p)).f. This patch by Than McIntosh detects this situation and issues an error message. This fixes https://golang.org/issue/21770. A test will be committed to the master testsuite in https://golang.org/cl/62331. 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 251574) +++ gcc/go/gofrontend/MERGE (working copy) @@ -1,4 +1,4 @@ -9d0d5c03a8086f5dd3a23e910abd6e470196973c +52ebad939927e6cbfb48dd277cef8db451e36533 The first line of this file holds the git revision number of the last merge done from the gofrontend repository. Index: gcc/go/gofrontend/types.cc =================================================================== --- gcc/go/gofrontend/types.cc (revision 251533) +++ gcc/go/gofrontend/types.cc (working copy) @@ -11829,6 +11829,12 @@ Type::bind_field_or_method(Gogo* gogo, c go_assert(st != NULL); if (type->struct_type() == NULL) { + if (dereferenced) + { + go_error_at(location, "pointer type has no field %qs", + Gogo::message_name(name).c_str()); + return Expression::make_error(location); + } go_assert(type->points_to() != NULL); expr = Expression::make_unary(OPERATOR_MULT, expr, location);