aboutsummaryrefslogtreecommitdiffhomepage
path: root/cgo/cgo.go
diff options
context:
space:
mode:
authorAyke van Laethem <[email protected]>2021-02-07 16:02:16 +0100
committerRon Evans <[email protected]>2021-02-11 09:51:15 +0100
commit2e9c3a1d8d5e59baee62ce12812f0ef37d112f33 (patch)
tree3f89a557d312c69c1466b0931a8ea22912551268 /cgo/cgo.go
parent550218264204aa62e9d602a1a380531040c18deb (diff)
downloadtinygo-2e9c3a1d8d5e59baee62ce12812f0ef37d112f33.tar.gz
tinygo-2e9c3a1d8d5e59baee62ce12812f0ef37d112f33.zip
cgo: add support for variadic functions
This doesn't yet add support for actually making use of variadic functions, but at least allows (unintended) variadic functions like the following to work: void foo();
Diffstat (limited to 'cgo/cgo.go')
-rw-r--r--cgo/cgo.go17
1 files changed, 14 insertions, 3 deletions
diff --git a/cgo/cgo.go b/cgo/cgo.go
index 7cc61b9ce..73d26e1d8 100644
--- a/cgo/cgo.go
+++ b/cgo/cgo.go
@@ -54,9 +54,10 @@ type constantInfo struct {
// functionInfo stores some information about a CGo function found by libclang
// and declared in the AST.
type functionInfo struct {
- args []paramInfo
- results *ast.FieldList
- pos token.Pos
+ args []paramInfo
+ results *ast.FieldList
+ pos token.Pos
+ variadic bool
}
// paramInfo is a parameter of a CGo function (see functionInfo).
@@ -484,6 +485,16 @@ func (p *cgoPackage) addFuncDecls() {
Results: fn.results,
},
}
+ if fn.variadic {
+ decl.Doc = &ast.CommentGroup{
+ List: []*ast.Comment{
+ &ast.Comment{
+ Slash: fn.pos,
+ Text: "//go:variadic",
+ },
+ },
+ }
+ }
obj.Decl = decl
for i, arg := range fn.args {
args[i] = &ast.Field{