From patchwork Tue Jun 28 17:25:40 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Lance Taylor X-Patchwork-Id: 55510 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 0CA96386DC63 for ; Tue, 28 Jun 2022 17:26:24 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 0CA96386DC63 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1656437184; bh=9vVQQXqlhw41MzMpKyjt+ztNmDHrnxa4b3XSekDhx6o=; h=Date:Subject:To:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=ARq5oGcKfr11YbwWrmF0kVp59bG/AMw9TnEFjyL8D9EHNPsLKszjzZ9fBa01HXee/ 7UL6sX7gaPovmJr4gbYhfcBDYkPXP7mP8w2+yrVZvbClFLlHu8mzGLHZfqbGRSSRBJ hAilndlW4mNQkd+EjPC1XvELcsz8Fx5jqrxNXv/s= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-pg1-x531.google.com (mail-pg1-x531.google.com [IPv6:2607:f8b0:4864:20::531]) by sourceware.org (Postfix) with ESMTPS id C9611385736C for ; Tue, 28 Jun 2022 17:25:53 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org C9611385736C Received: by mail-pg1-x531.google.com with SMTP id h192so12853838pgc.4 for ; Tue, 28 Jun 2022 10:25:53 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=9vVQQXqlhw41MzMpKyjt+ztNmDHrnxa4b3XSekDhx6o=; b=Y1B6nCAlvWKeBq9LV5JEe2BO0AaviG6sUCfuKu1b9NRr8wut7d0Ig6z0UJAUGu6+fN D94v1NraKHvZIkUND7FbwdSLsDMhFEGxLPnPrgvEvgzSAh85D3gQAbQRL+/Bc1cd26oQ 0NTFNz4tU1DRcY1Y9VejNg9s1I3xOz7Vhc1l4yfvbcSqqT6y5TuLWcbFiiCYhNYWpyEX Pj6FdWfgCX5SJsDcERvkgt8h+1E7GbCziU5fmTc575G7TxWhq6BYM2bnqZVpQFhMmFG+ 45INcAXRTu+G/FOCWFIr3XAmywX03EhRuNV+GvuTpOJiFj1iTFVBEQVYQoNZgjzdEpkc bgOg== X-Gm-Message-State: AJIora/X0UErdDITgpqbye0fYpon19GidNQuhLMeD5x714aVmTCE1GRX piHv3Xymyqgxzjs0zCwHkqoBKc99tmv0edbhmd4dgIQvIhQAUg== X-Google-Smtp-Source: AGRyM1vnTrVLCR5QOEzeo9bOrQ6FiHoA1hM/9Dmc3QZal/jrHYPZuLMbknFtnu7FIEtU4jJ3gWNUiAvLM1jTP2Ki3Vg= X-Received: by 2002:a05:6a00:15cc:b0:525:8b07:71c3 with SMTP id o12-20020a056a0015cc00b005258b0771c3mr5809995pfu.57.1656437151929; Tue, 28 Jun 2022 10:25:51 -0700 (PDT) MIME-Version: 1.0 Date: Tue, 28 Jun 2022 10:25:40 -0700 Message-ID: Subject: Go patch committed: Use package path with embedded builtin To: gcc-patches , gofrontend-dev X-Spam-Status: No, score=-9.6 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Ian Lance Taylor via Gcc-patches From: Ian Lance Taylor Reply-To: Ian Lance Taylor Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" This patch to the Go frontend changes the mangled name of a struct to use the package path with an embedded builtin type. The test case is https://go.dev/cl/414235. This fixes https://go.dev/issue/52856. Bootstrapped and ran Go testsuite on x86_64-pc-linux-gnu. Committed to mainline. Ian 74956337e8276e5bc9524104b01c147374dd94e7 diff --git a/gcc/go/gofrontend/MERGE b/gcc/go/gofrontend/MERGE index 551ea650acf..13cb6ea4046 100644 --- a/gcc/go/gofrontend/MERGE +++ b/gcc/go/gofrontend/MERGE @@ -1,4 +1,4 @@ -d5b4abed2f206e492890acc20738e89617ea542c +c7238f58a26131b7611eff6f555cab02af8a623c The first line of this file holds the git revision number of the last merge done from the gofrontend repository. diff --git a/gcc/go/gofrontend/names.cc b/gcc/go/gofrontend/names.cc index f85d84ceadf..dac7f20f5c1 100644 --- a/gcc/go/gofrontend/names.cc +++ b/gcc/go/gofrontend/names.cc @@ -831,15 +831,28 @@ Struct_type::do_mangled_name(Gogo* gogo, std::string* ret, ret->push_back(' '); } - // For an anonymous field with an alias type, the field name - // is the alias name. - if (p->is_anonymous() - && p->type()->named_type() != NULL - && p->type()->named_type()->is_alias()) - p->type()->named_type()->append_symbol_type_name(gogo, true, ret, - is_non_identifier); + const Type* ft = p->type(); + const Named_type* nt = ft->named_type(); + + if (p->is_anonymous() && nt != NULL && nt->is_builtin()) + { + // For an embedded field with a builtin type, we must + // include a package path. Otherwise embedding builtin + // types in different packages will produce identical + // types, which shouldn't happen because the builtin + // types are not exported. + ret->append(gogo->pkgpath()); + ret->push_back('.'); + nt->append_symbol_type_name(gogo, true, ret, is_non_identifier); + } + else if (p->is_anonymous() && nt != NULL && nt->is_alias()) + { + // For an anonymous field with an alias type, the field name + // is the alias name. + nt->append_symbol_type_name(gogo, true, ret, is_non_identifier); + } else - this->append_mangled_name(p->type(), gogo, ret, is_non_identifier); + this->append_mangled_name(ft, gogo, ret, is_non_identifier); if (p->has_tag()) {