]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/cgo: add C declaration parameter unused attribute
authorIan Lance Taylor <iant@golang.org>
Sat, 11 Jan 2025 00:22:20 +0000 (16:22 -0800)
committerGopher Robot <gobot@golang.org>
Mon, 3 Feb 2025 16:24:47 +0000 (08:24 -0800)
Fixes #71225

Change-Id: I3e60fdf632f2aa0e63b24225f13e4ace49906925
Reviewed-on: https://go-review.googlesource.com/c/go/+/642196
Reviewed-by: David Chase <drchase@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
src/cmd/cgo/out.go
test/fixedbugs/issue71225.go [new file with mode: 0644]

index 5e67cc2d3345985d9ac114f12cfd50accbd90789..b3e4c7ccdf0cf32db0c32ffc7ef097225c6c18e9 100644 (file)
@@ -1094,7 +1094,7 @@ func (p *Package) writeExports(fgo2, fm, fgcc, fgcch io.Writer) {
                // This unpacks the argument struct above and calls the Go function.
                fmt.Fprintf(fgo2, "func _cgoexp%s_%s(a *%s) {\n", cPrefix, exp.ExpName, gotype)
 
-               fmt.Fprintf(fm, "void _cgoexp%s_%s(void* p){}\n", cPrefix, exp.ExpName)
+               fmt.Fprintf(fm, "void _cgoexp%s_%s(void* p __attribute__((unused))){}\n", cPrefix, exp.ExpName)
 
                fmt.Fprintf(fgo2, "\t")
 
diff --git a/test/fixedbugs/issue71225.go b/test/fixedbugs/issue71225.go
new file mode 100644 (file)
index 0000000..8a6b313
--- /dev/null
@@ -0,0 +1,19 @@
+// build
+
+//go:build cgo
+
+// Copyright 2025 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
+
+// #cgo CFLAGS: -Werror -Wunused-parameter
+import "C"
+
+func main() {
+}
+
+//export Fn
+func Fn() {
+}