1
0
mirror of https://github.com/golang/go synced 2024-11-26 01:07:57 -07:00

cmd/compile: mark pointer to noalg type as noalg

When the compiler writes PtrToThis field of noalg type, it generates
its pointer type. Mark them as noalg to prevent put them in typelinks.

Fixes #65957

Change-Id: Icbc3b18bc866f9138c7648e42dd500a80326f72b
Reviewed-on: https://go-review.googlesource.com/c/go/+/567335
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Auto-Submit: Keith Randall <khr@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Keith Randall <khr@google.com>
This commit is contained in:
zuojunwei.1024 2024-02-27 19:14:00 +08:00 committed by Gopher Robot
parent e8b6d0c9cd
commit b8c76effd9
4 changed files with 41 additions and 0 deletions

View File

@ -657,6 +657,9 @@ func NewPtr(elem *Type) *Type {
if elem.HasShape() {
t.SetHasShape(true)
}
if elem.Noalg() {
t.SetNoalg(true)
}
return t
}

View File

@ -0,0 +1,12 @@
// Copyright 2024 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package a
var s any
//go:noinline
func F() {
s = new([4]int32)
}

View File

@ -0,0 +1,19 @@
// Copyright 2024 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package main
import (
"./a"
"reflect"
)
var s = []rune{0, 1, 2, 3}
func main() {
m := map[any]int{}
k := reflect.New(reflect.ArrayOf(4, reflect.TypeOf(int32(0)))).Elem().Interface()
m[k] = 1
a.F()
}

View File

@ -0,0 +1,7 @@
// rundir
// Copyright 2024 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package ignored