From patchwork Fri Feb 2 23:04:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Lance Taylor X-Patchwork-Id: 1894809 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=golang-org.20230601.gappssmtp.com header.i=@golang-org.20230601.gappssmtp.com header.a=rsa-sha256 header.s=20230601 header.b=yv4rFn0j; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=server2.sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4TRWZL4F22z1yQ0 for ; Sat, 3 Feb 2024 10:04:58 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 66D083857C4B for ; Fri, 2 Feb 2024 23:04:56 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-yw1-x112c.google.com (mail-yw1-x112c.google.com [IPv6:2607:f8b0:4864:20::112c]) by sourceware.org (Postfix) with ESMTPS id C2712385842F for ; Fri, 2 Feb 2024 23:04:30 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org C2712385842F Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=golang.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=golang.org ARC-Filter: OpenARC Filter v1.0.0 sourceware.org C2712385842F Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::112c ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1706915073; cv=none; b=Q1uxEd4S1ETw848wiSYQ+RMC8fXvPLmbcdEpJsK9emMXjiIPiUEdhfM9MdpCRH1zgfXdKxsxRho5NCXmbKPHxCkcrVNPZEk4oUoKcgxN1tfIe+DINndloqgO5S01E4f4fa2sFFf62UQSnLAarLak0fW6Q4jt3uBLWd/UtOX+QpE= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1706915073; c=relaxed/simple; bh=7shxU79jMtHVYWgTwYleYemwt4JF3MXArfstq11v+jk=; h=DKIM-Signature:MIME-Version:From:Date:Message-ID:Subject:To; b=Pb2xn2Tx90tSKMPz9K2OksCztj2WqV5xKHwMn4WKgLV5TR+5K7XP0k7mqmtH6iyK3Stq+JFEeCAIl+O2EmUPyXGnGShGnSf6d0E+14uuW5u2y3x5Spy3CysZgGPRfkFYO84Qrl27CFnECDe53MWHcMMaWtmwhjEcJ0s9K8sDSyQ= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-yw1-x112c.google.com with SMTP id 00721157ae682-60417488f07so28360857b3.1 for ; Fri, 02 Feb 2024 15:04:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=golang-org.20230601.gappssmtp.com; s=20230601; t=1706915070; x=1707519870; darn=gcc.gnu.org; h=to:subject:message-id:date:from:mime-version:from:to:cc:subject :date:message-id:reply-to; bh=BInBsysexv9A1DRUU9dKekXe1CsjjO5ChA/0IbGmWWg=; b=yv4rFn0jYVTSGJJ+5fdcvsQIpI6N7X+1JlO1m4lV2qbX2hrE2nJY6YPGt++mnSO6cw hhvSYOqb7ge8QHXmd7Y8zZp8fpG8U53z+UYxahtyfOC2sbbMRTGJCuSay56/6gfQ4RvV CjhcceWfnZspFKTG+IIHwW8MjBl+UMcbGWXg/ki2uKAyA4hZXmzb0tQ7mur7j0s6Xu8L kNJ6jLWjUyuyBbOleiB2bpTifmmvO/b6vUCZ8QJZZHQSh/3iEgD+DF+nR2kDV+mj4Q3L FlA7/fcpX8B+iKYIjq0f5aZ5FvUXNLrvp4vPvzwM3aSu6E4rx8E1lw0QhlhUKTq9q7QX GBmA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706915070; x=1707519870; h=to:subject:message-id:date:from:mime-version:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=BInBsysexv9A1DRUU9dKekXe1CsjjO5ChA/0IbGmWWg=; b=qOAT5lkgmmwSZeFUEFq9vEMAzaOLd0TVsADeSdvMd/68PMl2UngHZb5teuKbSxLoya maJ2LxmyaS5gFfIJF+Mz7F0uO4vkCYzP4ri0xY8uZXRjMAbblMrXJEdy7eIHXbR+8aI5 DVyFswLNDqYTq5+QtebvI3l4C8BVrGOXSiiAwQ2QxPwGpn127yOnPHQNT0CEFtY2fcNP 9K2DaMs+UqkWUv65YCl21T2KMetdAgJrqfal4UU3/lvaIzkclri2nkqN+D1IM8UZR7Kg Zj6GWMsjQCjA2y28ESbkMpONwhx/+y1vvQBXHKZ1Uac2ZL+S5x6P+CeAs0yzUALNNPe5 Ejcg== X-Gm-Message-State: AOJu0YyHv9L1B+RrE0DMi98mMJ9KPxPvVnq7XaiLRuzWJ3gtaclTouvV 7wCWqRe7476iDmp+La42mCne2PjyughdeFQg5xz8Eg/q4MxP7CcV3TPlUxCFX84S7t67h9dRJT9 nHt5EhXS6G56YGoqadUr0E2kXvPmmw7NvCCqVPE/74Cc3drqlXSQ= X-Google-Smtp-Source: AGHT+IEyi704lIuGSj0f0uQuhaZd1w5+IKBQzIWOgevDahHiNIJZtPPv+QCwQtZxfcBy9CQ9UFdY8/2snPUrPrIMX6E= X-Received: by 2002:a0d:ccc3:0:b0:5f6:d447:b85a with SMTP id o186-20020a0dccc3000000b005f6d447b85amr7634868ywd.7.1706915069756; Fri, 02 Feb 2024 15:04:29 -0800 (PST) MIME-Version: 1.0 From: Ian Lance Taylor Date: Fri, 2 Feb 2024 15:04:18 -0800 Message-ID: Subject: Go patch committed: Export the type "any" as a builtin To: gcc-patches , gofrontend-dev X-Spam-Status: No, score=-8.9 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.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org This patch to the Go frontend exports the type "any" as a builtin. Otherwise we can't tell the difference between builtin type "any" and a locally defined type "any". This will require updates to the gccgo export data parsers in the main Go repo and the x/tools repo. These updates are https://go.dev/cl/537195 and https://go.dev/cl/537215. Bootstrapped and ran Go testsuite on x86_64-pc-linux-gnu. Committed to mainline. Ian e52d31804a910642c9817bdd400c290a593c98ef diff --git a/gcc/go/gofrontend/MERGE b/gcc/go/gofrontend/MERGE index c2a6032ae80..18281c6cd1e 100644 --- a/gcc/go/gofrontend/MERGE +++ b/gcc/go/gofrontend/MERGE @@ -1,4 +1,4 @@ -ddf3758e4a45ca2816fb68f3e4224501a3c4c438 +7ab229670f7dad1d79f33929f9a4f8e6e4a71526 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/export.cc b/gcc/go/gofrontend/export.cc index 7373deee310..40f6d5d4b2f 100644 --- a/gcc/go/gofrontend/export.cc +++ b/gcc/go/gofrontend/export.cc @@ -1661,6 +1661,7 @@ Export::register_builtin_types(Gogo* gogo) this->register_builtin_type(gogo, "error", BUILTIN_ERROR); this->register_builtin_type(gogo, "byte", BUILTIN_BYTE); this->register_builtin_type(gogo, "rune", BUILTIN_RUNE); + this->register_builtin_type(gogo, "any", BUILTIN_ANY); } // Register one builtin type in the export table. diff --git a/gcc/go/gofrontend/export.h b/gcc/go/gofrontend/export.h index 1f613434cab..be117ece2ce 100644 --- a/gcc/go/gofrontend/export.h +++ b/gcc/go/gofrontend/export.h @@ -51,8 +51,9 @@ enum Builtin_code BUILTIN_ERROR = -19, BUILTIN_BYTE = -20, BUILTIN_RUNE = -21, + BUILTIN_ANY = -22, - SMALLEST_BUILTIN_CODE = -21 + SMALLEST_BUILTIN_CODE = -22 }; // Export data version number. New export data is written with the diff --git a/gcc/go/gofrontend/import.cc b/gcc/go/gofrontend/import.cc index 21691fa5ff4..3cc8a720ee4 100644 --- a/gcc/go/gofrontend/import.cc +++ b/gcc/go/gofrontend/import.cc @@ -1408,6 +1408,7 @@ Import::register_builtin_types(Gogo* gogo) this->register_builtin_type(gogo, "error", BUILTIN_ERROR); this->register_builtin_type(gogo, "byte", BUILTIN_BYTE); this->register_builtin_type(gogo, "rune", BUILTIN_RUNE); + this->register_builtin_type(gogo, "any", BUILTIN_ANY); } // Register a single builtin type. diff --git a/libgo/go/go/internal/gccgoimporter/parser.go b/libgo/go/go/internal/gccgoimporter/parser.go index 48335fa6d8f..2161df7f368 100644 --- a/libgo/go/go/internal/gccgoimporter/parser.go +++ b/libgo/go/go/internal/gccgoimporter/parser.go @@ -187,7 +187,6 @@ func (p *parser) parseQualifiedNameStr(unquotedName string) (pkgpath, name strin // getPkg returns the package for a given path. If the package is // not found but we have a package name, create the package and // add it to the p.imports map. -// func (p *parser) getPkg(pkgpath, name string) *types.Package { // package unsafe is not in the imports map - handle explicitly if pkgpath == "unsafe" { @@ -904,6 +903,7 @@ const ( gccgoBuiltinERROR = 19 gccgoBuiltinBYTE = 20 gccgoBuiltinRUNE = 21 + gccgoBuiltinANY = 22 ) func lookupBuiltinType(typ int) types.Type { @@ -928,13 +928,13 @@ func lookupBuiltinType(typ int) types.Type { gccgoBuiltinERROR: types.Universe.Lookup("error").Type(), gccgoBuiltinBYTE: types.Universe.Lookup("byte").Type(), gccgoBuiltinRUNE: types.Universe.Lookup("rune").Type(), + gccgoBuiltinANY: types.Universe.Lookup("any").Type(), }[typ] } // Type = "<" "type" ( "-" int | int [ TypeSpec ] ) ">" . // // parseType updates the type map to t for all type numbers n. -// func (p *parser) parseType(pkg *types.Package, n ...any) types.Type { p.expect('<') t, _ := p.parseTypeAfterAngle(pkg, n...) @@ -1117,9 +1117,10 @@ func (p *parser) maybeCreatePackage() { } // InitDataDirective = ( "v1" | "v2" | "v3" ) ";" | -// "priority" int ";" | -// "init" { PackageInit } ";" | -// "checksum" unquotedString ";" . +// +// "priority" int ";" | +// "init" { PackageInit } ";" | +// "checksum" unquotedString ";" . func (p *parser) parseInitDataDirective() { if p.tok != scanner.Ident { // unexpected token kind; panic @@ -1170,15 +1171,16 @@ func (p *parser) parseInitDataDirective() { } // Directive = InitDataDirective | -// "package" unquotedString [ unquotedString ] [ unquotedString ] ";" | -// "pkgpath" unquotedString ";" | -// "prefix" unquotedString ";" | -// "import" unquotedString unquotedString string ";" | -// "indirectimport" unquotedString unquotedstring ";" | -// "func" Func ";" | -// "type" Type ";" | -// "var" Var ";" | -// "const" Const ";" . +// +// "package" unquotedString [ unquotedString ] [ unquotedString ] ";" | +// "pkgpath" unquotedString ";" | +// "prefix" unquotedString ";" | +// "import" unquotedString unquotedString string ";" | +// "indirectimport" unquotedString unquotedstring ";" | +// "func" Func ";" | +// "type" Type ";" | +// "var" Var ";" | +// "const" Const ";" . func (p *parser) parseDirective() { if p.tok != scanner.Ident { // unexpected token kind; panic