From 1b89dada1ae7e2378a06f0ffeebb31f925fb08e9 Mon Sep 17 00:00:00 2001 From: Ian Lance Taylor Date: Fri, 5 Jan 2018 16:52:53 -0800 Subject: [PATCH] cmd/cgo: support niladic macros for gccgo https://golang.org/cl/43970 changed writeOutputFunc to support niladic function-like macros; apply the corresponding change to writeGccgoOutputFunc. Updates #10715 Updates #18720 Change-Id: I5decb1d37ec71507466ade2eeda4b89c8785eaef Reviewed-on: https://go-review.googlesource.com/86475 Run-TryBot: Ian Lance Taylor TryBot-Result: Gobot Gobot Reviewed-by: Hiroshi Ioka Reviewed-by: Brad Fitzpatrick Reviewed-by: Austin Clements --- src/cmd/cgo/out.go | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/cmd/cgo/out.go b/src/cmd/cgo/out.go index 44a00d8154f..070429f442d 100644 --- a/src/cmd/cgo/out.go +++ b/src/cmd/cgo/out.go @@ -695,14 +695,18 @@ func (p *Package) writeGccgoOutputFunc(fgcc *os.File, n *Name) { fmt.Fprintf(fgcc, "(void*)") } } - fmt.Fprintf(fgcc, "%s(", n.C) - for i := range n.FuncType.Params { - if i > 0 { - fmt.Fprintf(fgcc, ", ") + if n.Kind == "macro" { + fmt.Fprintf(fgcc, "%s;\n", n.C) + } else { + fmt.Fprintf(fgcc, "%s(", n.C) + for i := range n.FuncType.Params { + if i > 0 { + fmt.Fprintf(fgcc, ", ") + } + fmt.Fprintf(fgcc, "p%d", i) } - fmt.Fprintf(fgcc, "p%d", i) + fmt.Fprintf(fgcc, ");\n") } - fmt.Fprintf(fgcc, ");\n") fmt.Fprintf(fgcc, "\t_cgo_tsan_release();\n") if t := n.FuncType.Result; t != nil { fmt.Fprintf(fgcc, "\treturn ")