aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/link/internal/ld/dwarf_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'src/cmd/link/internal/ld/dwarf_test.go')
-rw-r--r--src/cmd/link/internal/ld/dwarf_test.go23
1 files changed, 21 insertions, 2 deletions
diff --git a/src/cmd/link/internal/ld/dwarf_test.go b/src/cmd/link/internal/ld/dwarf_test.go
index 3d112d97a4..db9002491e 100644
--- a/src/cmd/link/internal/ld/dwarf_test.go
+++ b/src/cmd/link/internal/ld/dwarf_test.go
@@ -1749,7 +1749,9 @@ func main() {
}
func TestDictIndex(t *testing.T) {
- // Check that variables with a parametric type have a dictionary index attribute
+ // Check that variables with a parametric type have a dictionary index
+ // attribute and that types that are only referenced through dictionaries
+ // have DIEs.
testenv.MustHaveGoBuild(t)
if runtime.GOOS == "plan9" {
@@ -1765,6 +1767,8 @@ package main
import "fmt"
+type CustomInt int
+
func testfn[T any](arg T) {
var mapvar = make(map[int]T)
mapvar[0] = arg
@@ -1772,7 +1776,7 @@ func testfn[T any](arg T) {
}
func main() {
- testfn("test")
+ testfn(CustomInt(3))
}
`
@@ -1829,4 +1833,19 @@ func main() {
t.Errorf("could not find DW_AT_go_dict_index attribute offset %#x (%T)", off, entry.Val(intdwarf.DW_AT_go_dict_index))
}
}
+
+ rdr.Seek(0)
+ ex := examiner{}
+ if err := ex.populate(rdr); err != nil {
+ t.Fatalf("error reading DWARF: %v", err)
+ }
+ for _, typeName := range []string{"main.CustomInt", "map[int]main.CustomInt"} {
+ dies := ex.Named(typeName)
+ if len(dies) != 1 {
+ t.Errorf("wanted 1 DIE named %s, found %v", typeName, len(dies))
+ }
+ if dies[0].Val(intdwarf.DW_AT_go_runtime_type).(uint64) == 0 {
+ t.Errorf("type %s does not have DW_AT_go_runtime_type", typeName)
+ }
+ }
}