File tree 5 files changed +59
-1
lines changed
src/cmd/compile/internal/typecheck 5 files changed +59
-1
lines changed Original file line number Diff line number Diff line change @@ -1692,6 +1692,7 @@ func (w *exportWriter) expr(n ir.Node) {
1692
1692
isBuiltin := n .BuiltinOp != ir .OXXX
1693
1693
w .bool (isBuiltin )
1694
1694
if isBuiltin {
1695
+ w .bool (n .Sym ().Pkg == types .UnsafePkg )
1695
1696
w .string (n .Sym ().Name )
1696
1697
break
1697
1698
}
Original file line number Diff line number Diff line change @@ -1269,7 +1269,11 @@ func (r *importReader) node() ir.Node {
1269
1269
case ir .ONAME :
1270
1270
isBuiltin := r .bool ()
1271
1271
if isBuiltin {
1272
- return types .BuiltinPkg .Lookup (r .string ()).Def .(* ir.Name )
1272
+ pkg := types .BuiltinPkg
1273
+ if r .bool () {
1274
+ pkg = types .UnsafePkg
1275
+ }
1276
+ return pkg .Lookup (r .string ()).Def .(* ir.Name )
1273
1277
}
1274
1278
return r .localName ()
1275
1279
Original file line number Diff line number Diff line change
1
+ // Copyright 2021 The Go Authors. All rights reserved.
2
+ // Use of this source code is governed by a BSD-style
3
+ // license that can be found in the LICENSE file.
4
+
5
+ package a
6
+
7
+ import "unsafe"
8
+
9
+ func F [T any ]() uintptr {
10
+ var t T
11
+ return unsafe .Sizeof (t )
12
+ }
13
+
14
+ func G [T any ]() uintptr {
15
+ var t T
16
+ return unsafe .Alignof (t )
17
+ }
18
+
19
+ //func H[T any]() uintptr {
20
+ // type S struct {
21
+ // a T
22
+ // b T
23
+ // }
24
+ // var s S
25
+ // return unsafe.Offsetof(s.b)
26
+ //}
Original file line number Diff line number Diff line change
1
+ // Copyright 2021 The Go Authors. All rights reserved.
2
+ // Use of this source code is governed by a BSD-style
3
+ // license that can be found in the LICENSE file.
4
+
5
+ package main
6
+
7
+ import "a"
8
+
9
+ func main () {
10
+ if a .F [int64 ]() != 8 {
11
+ panic ("bad" )
12
+ }
13
+ if a .G [int8 ]() != 1 {
14
+ panic ("bad" )
15
+ }
16
+ // TODO: enable once 47631 is fixed.
17
+ //if a.H[int64]() != 8 {
18
+ // panic("bad")
19
+ //}
20
+ }
Original file line number Diff line number Diff line change
1
+ // rundir -G=3
2
+
3
+ // Copyright 2021 The Go Authors. All rights reserved.
4
+ // Use of this source code is governed by a BSD-style
5
+ // license that can be found in the LICENSE file.
6
+
7
+ package ignored
You can’t perform that action at this time.
0 commit comments