diff options
author | Ian Lance Taylor <iant@golang.org> | 2021-09-15 16:11:37 -0700 |
---|---|---|
committer | Ian Lance Taylor <iant@golang.org> | 2021-09-16 23:56:28 +0000 |
commit | 265b59aefdd383fc60fcfc7a2838018b16d1d29a (patch) | |
tree | 919b9deed9cba48459251de246543b23ee2da0a5 /misc | |
parent | 4efdaa7bc7220fad0177842d0009285ca429a823 (diff) | |
download | go-265b59aefdd383fc60fcfc7a2838018b16d1d29a.tar.gz go-265b59aefdd383fc60fcfc7a2838018b16d1d29a.zip |
cmd/cgo: for godefs, don't let field prefix removal cause duplicates
Fixes #48396
Change-Id: Idd7cb66536ef513806c472d394a929bc271fc26b
Reviewed-on: https://go-review.googlesource.com/c/go/+/350159
Trust: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Matt Layher <mdlayher@gmail.com>
Diffstat (limited to 'misc')
-rw-r--r-- | misc/cgo/testgodefs/testdata/issue48396.go | 18 | ||||
-rw-r--r-- | misc/cgo/testgodefs/testdata/main.go | 3 | ||||
-rw-r--r-- | misc/cgo/testgodefs/testgodefs_test.go | 1 |
3 files changed, 22 insertions, 0 deletions
diff --git a/misc/cgo/testgodefs/testdata/issue48396.go b/misc/cgo/testgodefs/testdata/issue48396.go new file mode 100644 index 0000000000..d4c192403f --- /dev/null +++ b/misc/cgo/testgodefs/testdata/issue48396.go @@ -0,0 +1,18 @@ +// Copyright 2021 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. +// +// +build ignore + +package main + +/* +// from <linux/kcm.h> +struct issue48396 { + int fd; + int bpf_fd; +}; +*/ +import "C" + +type Issue48396 C.struct_issue48396 diff --git a/misc/cgo/testgodefs/testdata/main.go b/misc/cgo/testgodefs/testdata/main.go index 4a3f6a701c..5c670f3d32 100644 --- a/misc/cgo/testgodefs/testdata/main.go +++ b/misc/cgo/testgodefs/testdata/main.go @@ -28,6 +28,9 @@ var v7 = S{} // Test that #define'd type is fully defined var _ = issue38649{X: 0} +// Test that prefixes do not cause duplicate field names. +var _ = Issue48396{Fd: 1, Bpf_fd: 2} + func main() { pass := true diff --git a/misc/cgo/testgodefs/testgodefs_test.go b/misc/cgo/testgodefs/testgodefs_test.go index aae3404360..7628ffc595 100644 --- a/misc/cgo/testgodefs/testgodefs_test.go +++ b/misc/cgo/testgodefs/testgodefs_test.go @@ -25,6 +25,7 @@ var filePrefixes = []string{ "issue37621", "issue38649", "issue39534", + "issue48396", } func TestGoDefs(t *testing.T) { |